Skip to content

Instantly share code, notes, and snippets.

View xuchunyang's full-sized avatar

Xu Chunyang xuchunyang

View GitHub Profile
@xuchunyang
xuchunyang / highlight-some-text.el
Created May 31, 2016 10:10
Reply to https://emacs-china.org/t/topic/454/7 - 高亮特定字符串的一个方法
;; 用绿色高亮「申请人」、黄色高亮「被申请人」
(defun my-highlight-some-text ()
(hi-lock-set-pattern+ "被申请人" 0 'hi-yellow)
(hi-lock-set-pattern+ "[^被]\\(申请人\\)" 1 'hi-green))
(add-hook 'org-mode-hook #'my-highlight-some-text)
(defun hi-lock-set-pattern+ (regexp group face)
@xuchunyang
xuchunyang / init.el
Created November 26, 2016 10:35
exiting init file early
;; init.el ends here
(with-current-buffer " *load*" (goto-char (point-max)))
(the following does not matter nay more)
@xuchunyang
xuchunyang / 0_reuse_code.js
Created January 29, 2016 11:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
(helm :sources (helm-build-sync-source "Buffers"
:candidates (lambda () (helm-buffer-list))
:filtered-candidate-transformer
'(helm-skip-boring-buffers
helm-buffers-sort-transformer)
:volatile t)
:buffer "*helm my buffers*")
@xuchunyang
xuchunyang / incf-at-point.el
Created October 4, 2015 05:25
Increment number at point by 1.
(defun incf-at-point ()
"Increment number at point by 1."
(interactive)
(let ((number (number-at-point))
bounds beg end)
(if number
(progn
(setq bounds (bounds-of-thing-at-point 'sexp))
(setq beg (car bounds)
end (cdr bounds))
@xuchunyang
xuchunyang / foo.el
Created October 3, 2015 13:43
Use mouse to select a window for file/buffer
(let* ((ev (read-event "Select a window with mouse: " nil))
(pos (when (consp ev) (nth 1 ev)))
(wind (when pos (posn-window pos))))
(message-box "%s - %s" (current-buffer) ev))
@xuchunyang
xuchunyang / swap-value-of-variables.el
Created September 7, 2015 07:40
Swap values of variables and Swap car and cdr of cons cell in Emacs Lisp
(let ((a 1) (b 2))
(setq a (prog1 b (setq b a)))
(list a b))
;; => (2 1)
(let ((con '(1 . 2)))
(setcar con (prog1 (cdr con)
(setcdr con (car con))))
con)
;; => (2 . 1)
@xuchunyang
xuchunyang / helm-config-0x01.el
Created September 1, 2015 17:32
[helm] Hide mode line and minibuffer content
(setq helm-echo-input-in-header-line t)
;; Hide minibuffer when the above option is on.
(add-hook 'helm-minibuffer-set-up-hook
#'helm-hide-minibuffer-maybe)
;; Don't use helm's own displaying mode line function
(fset 'helm-display-mode-line #'ignore)
(add-hook 'helm-after-initialize-hook
(defun hide-mode-line-in-helm-buffer ()
@xuchunyang
xuchunyang / gist:103c4dc2fc31cc3b1b9b
Created August 19, 2015 11:29
Pick up a Emacs recent file to edit from the Command Line
# Put it in your .zshrc or .bashrc
function ef { sed -n 's/^ *"\(.*\)"/\1/p' ~/.emacs.d/recentf | pick | xargs $EDITOR }