This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (prefix event) | |
"Select helm candidate by mouse. With PREFIX, also execute its first action." | |
(interactive "P\ne") | |
(when (helm-alive-p) | |
(with-helm-buffer | |
(let* ((posn (elt event 1)) | |
(cursor (line-number-at-pos (point))) | |
(pointer (line-number-at-pos (posn-point posn)))) | |
(helm--next-or-previous-line (if (> pointer cursor) | |
'next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; elisp-cl-lib-01.el --- | |
;;; | |
(require 'cl-lib) | |
;;; Common Lisp Function Argument Lists | |
(cl-defun foo (a &optional b &key c d (e 17)) | |
(message "%S %S %S %S %S" a b c d e)) ;; => foo | |
(foo 1 2 :d 3 :c 4) ;; => "1 2 4 3 17" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Advice Functions | |
(defun my-tracing-function (orig-fun &rest args) | |
"My tracing functions." | |
;; (message "Old buffer name" (buffer-name)) | |
(message "ace-window called with args %S" args) | |
(let ((res (apply orig-fun args))) | |
(message "ace-window returned %S" res) | |
res)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Sequences | |
;; | |
;;; Types: | |
;; 1. list | |
;; 2. vector | |
;; 3. string | |
;; 4. bool-vector | |
;; 5. char-table | |
;; 6. `nil' | |
;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setf (buffer-string) (buffer-name)) | |
(setf (mark) 10 | |
(point) 20) | |
(setq my-list '(0 1 2 3 4 5)) | |
(cl-letf ((my-list)) | |
(message "%s" my-list)) ;; ==> "(0 1 2 3 4 5)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; elisp-minor-mode.el --- Write Minor Mode | |
;;; Commentary: | |
;; | |
;; See Info node `(elisp) Minor Mode' | |
;;; `foo-mode' variable and functions, `foo-mode-hook' are define via this macro. | |
(define-minor-mode foo-mode | |
"Foo minor mode." | |
;; The initial value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; elisp-helm-demo-02.el --- Write helm extensions demo 02 | |
;; Demo 01 --- with matched got highlighted with `helm-build-in-buffer-source' | |
(setq a-helm-source | |
(helm-build-in-buffer-source "*a helm source*" | |
:init (lambda () | |
(let ((text (buffer-string))) | |
(with-current-buffer (helm-candidate-buffer 'global) | |
(insert text)))) | |
:real-to-display (lambda (cand) (upcase cand)) ; Real displayed stuff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Demo 1 | |
;;; `candidates' is a real list | |
(setq simple-helm-source | |
'((name . "A simple source") | |
(candidates . (1 2 3 4)) | |
(action . (lambda (candidate) (message "%s" candidate))))) | |
(helm :sources '(simple-helm-source)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Emacs Lisp Process | |
(call-process "pwd" nil t nil) | |
(call-process "grep" nil "bar" nil "root" "/etc/passwd") | |
(let ((default-directory "/tmp/")) | |
(call-process "pwd" nil t)) | |
(call-process-region 1 6 "cat" nil t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; elisp-parse-xml.el --- demo for parse xml in Emacs Lisp | |
;;; Created: 2015/04/01 | |
;;; URL: $gist_url$ | |
(insert-file-contents "~/ss.xml") | |
;; ==> | |
;; <?xml version="1.0" encoding="UTF-8"?> | |
;; <note> | |
;; <to>Tove</to> |