Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / init.el
Last active April 16, 2019 10:16
comment out the STDOUT part
;; ;; omit the result to STDOUT after return when using emacs/emacsclient -e "expression"
;; (when (not (display-graphic-p))
;; (define-advice server-eval-and-print (:filter-args (args) no-print)
;; (list (car args) nil)))
(setq org-agenda-custom-commands
'(("c" "Simple agenda view"
((tags "PRIORITY=\"A\""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "High-priority unfinished tasks:")))
@c02y
c02y / init.el
Last active April 15, 2019 10:06
STDOUT in terminal according to DISPLAY
;; omit the result to STDOUT after return when using emacs/emacsclient -e "expression"
(when (not (display-graphic-p))
(define-advice server-eval-and-print (:filter-args (args) no-print)
(list (car args) nil)))
(bind-keys :map prog-mode-map
("C-c a a" . align)
("C-c a r" . align-regexp))
# Put this into org-mode-map
@c02y
c02y / diffs
Last active April 15, 2019 04:05
diffs to replace multiple diff alias/abbr
function diffs -d "all kinds of diff features"
set -l options 'f' 'w' 'l' 'L' 'W' 'h'
argparse -n diffs $options -- $argv
or return
if set -q _flag_h
echo "diffs [-f/-w/-l/-L/-W/-h]"
echo " no option --> side by side, only diffs"
echo " -f --> like no argument, but print whole files"
echo " -w --> like no argument, but ignore all white spaces"
@c02y
c02y / init.el
Last active April 12, 2019 09:54
helm-moccur-map
change helm-moccur-map tp helm-occur-map since it is rewriten
;; use TAB to complete when using C-x C-f, use C-i for original TAB/C-i feature
(define-key helm-find-files-map "\t" 'helm-execute-persistent-action)
(setq helm-ff-auto-update-initial-value t) ;file name auto-expansion github-issue-1616
(setq projectile-enable-caching nil)
(setq projectile-git-submodule-command nil) ; make projectile work for repo contains submodules
@c02y
c02y / init.el
Last active April 11, 2019 07:44
helm-swoop edit problem
download helm-swoop.el from https://raw.githubusercontent.com/ashiklom/helm-swoop/master/helm-swoop.el
since it fixes the edit problem in helm-swoop
(bind-keys*
("C-x s" . helm-swoop)
("C-x S" . helm-multi-swoop))
delete "C-x e" binding
@c02y
c02y / config.fish
Last active April 11, 2019 10:28
emm function
remove emm and t functions in config.fish and just use them in ~/.local/bin/
alias less 'less -x4 -RM -s +Gg' # -x4 to set the tabwidth to 4 instead default 8
@c02y
c02y / emm
Last active April 26, 2019 11:32
emm function for bash
#!/bin/bash
# 0. put this script into ~/.local/bin/
# 1. Create a emacsclient.desktop in ~/.local/share/applications/emacsclient.desktop
# 1.1 if you installed Emacs using pkg manager instead of anaconda3, omit this step
# 1.2 if you are using non-GUI or launcher is unnecessary, omit this step including the next
# 1.3 if you are using an OS without systemctl installed, omit this step including the next
#
# emacsclient.desktop:
#
@c02y
c02y / stowsh
Last active April 7, 2019 05:54
one single bash script stowsh to replace stow
#!/usr/bin/env bash
_runcommands() {
if [[ $DRYRUN == 1 ]] || [[ $VERBOSE -gt 1 ]]; then
echo "$@"
fi
if [[ $DRYRUN != 1 ]]; then
eval "$@"
fi
}
@c02y
c02y / init.el
Last active March 28, 2019 06:14
alias and emacsclient
(defalias 'eit-list 'benchmark-init/show-durations-tabulated)
;; (setq desktop-save 'ask)
;;desktop-save ask means always ask
;; (desktop-save-mode nil)
(setq confirm-kill-emacs 'y-or-n-p)
(defun ask-before-closing ()
"Prompt for confirmation for emacsclient(not daemon) like confirm-kill-emacs for running Emacs without daemon."
(interactive)
(if (y-or-n-p (format "Really exit Emacs? "))
@c02y
c02y / init.el
Created March 26, 2019 14:05
highlight-changes tweak
(if (daemonp)
;; for emacs --deamon, highlight-change doesn't work with daemon
(add-hook 'after-make-frame-functions
(lambda (frame)
(select-frame frame)
(bind-keys*
("C-h C-b" . diff-buffer-with-file)
("C-h C-v" . highlight-changes-visible-mode)
("M-<f1>" . highlight-changes-previous-change)
("M-<f2>" . highlight-changes-next-change))