`(defvar ,_ ,_)
`(lambda (,arg) (,fun ,arg))
For example, to find all (likely) callers of pcase-let
, use M-x
el-search-load-path
with:
`(pcase-let . ,_)
Try the package elisp-refs.
info:elisp#Key Sequences
To replace
(define-key (current-global-map) [?\C-x ?l] #'count-lines-page)
(define-key (current-global-map) "\C-xl" #'count-lines-page)
into
(define-key (current-global-map) (kbd "C-x l") #'count-lines-page)
use
M-x el-search-query-replace RET
`(define-key ,map ,(and key (or (pred vectorp) (pred stringp))) ,cmd)
->
`(define-key ,map (kbd ,(key-description key)) ,cmd)
RET
(pred stringp)
Notes that dostring is also considered as string.
`(foo ,a ,b . ,rest)
->
`(foo ,b ,a . ,rest)
Change
(if x 100)
(if (not x) 100)
(if (< x 0)
"x < 0"
(if (= x 0) "x = 0" "x > 0"))
into
(when x 100)
(unless x 100)
(cond ((< x 0) "x < 0")
((= x 0) "x = 0")
(t "x > 0"))
via
(iffy-if repl) -> repl
For example, to replace
(push '("\\.rkt[dl]?\\'" . racket-mode) auto-mode-alist)
with
(add-to-list 'auto-mode-alist '("\\.rkt[dl]?\\'" . racket-mode))
use
`(push ,elt ,lst) -> `(add-to-list ',lst ,elt)
For example, to change
(mapc
(lambda (x)
(message "%s" (+ x 100)))
'(1 2 3))
into
(dolist (x '(1 2 3))
(message "%s" (+ x 100)))
use
`(mapc (lambda (,var) . ,body) ,list)
->
`(dolist (,var ,list) . ,body)
For example, to change
(mapcar (lambda (x) (* x x)) '(1 2 3))
into
(--map (* it it) '(1 2 3))
use
(defun transform-lambda-form-for---map (lambda-form)
(pcase-let ((`(lambda (,var) . ,body) lambda-form))
(macroexpand-1
`(cl-symbol-macrolet ((,var it))
,@body))))
and
`(mapcar ,lambda-form ,list)
->
`(--map ,(transform-lambda-form-for---map lambda-form) ,list)
(add-hook 'before-save-hook 'time-stamp)
(add-hook 'before-save-hook #'time-stamp)
`(add-hook ,hook (quote ,f))
->
`(add-hook ,hook (function ,f))
(define-key term-mode-map [?\C-c ?\C-j] 'term-char-mode)
(define-key term-mode-map [?\C-c ?\C-j] #'term-char-mode)
`(define-key ,m ,k (quote ,f))
->
`(define-key ,m ,k (function ,f))
such as cl-block/cl-return, catch/throw, pcase/app etc
(el-search-emacs-elisp-sources '(l ^ 'catch __ (contains (l ^ 'throw))))
(el-search-emacs-elisp-sources '(l ^ 'pcase __ (contains (l ^ 'app))))
比如 auto-insert
这个符号函数定义和变量定义同时存在。
排除掉函数调用以及一些定义:
(l (pred (lambda (x) (not (memq x '(quote defun defgroup defcustom))))) __ 'auto-insert __)