I'm trying to add new support to
(defun er/lisp-mode () (interactive) "Enhancement for lisp like #'() ,@()" (when (looking-at "\\(\\(`,?\\)\\|\\('?,?\\)\\|\\(,?@?\\)\\|\\(#?'?\\)\\)?(") (cond ((er/looking-back-on-line ",\\|@\\|?\\|#\\|'\\|`") (backward-char 1))) (set-mark (point)) (forward-list) (exchange-point-and-mark))) (defun er/add-lisp-mode-expansions () (make-variable-buffer-local 'er/try-expand-list) (setq er/try-expand-list (append er/try-expand-list '(er/lisp-mode)))) (use-package expand-region :ensure t :bind ("C-SPC" . er/expand-region) :hook ((lisp-mode slime-mode) . er/add-lisp-mode-expansions))
When I open the first
.lisp file, it looks fine.
But after the first file, it doesn't work:
expand-region will select all text of the entire buffer regardless of where I call
When I look at
er/try-expand-list in those buffers, it gives
(er/lisp-mode er/lisp-mode) in lisp-mode buffers, and
nil in buffers of other modes.
As far as I can see, it is
er/try-expand-list that controls the behaviour of
er/expand-region, so the problem is the wrong value of
er/try-expand-region, which should be composed from the original value provided by
er/lisp-mode added, depending on the mode of the buffer.
How should I fix it?