aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2016-05-02 23:58:15 +0200
committerLars Ingebrigtsen2016-05-02 23:58:15 +0200
commit1331467910537f4d85fa842c993ef2c48ebbf749 (patch)
treecb2c1a213399d9f1b9caedcd443ab0398603db82
parent33d6250a9384e33531d6ec30f29613eb789c57b4 (diff)
downloademacs-1331467910537f4d85fa842c993ef2c48ebbf749.tar.gz
emacs-1331467910537f4d85fa842c993ef2c48ebbf749.zip
Allow eval-ing named character literals
* lisp/progmodes/elisp-mode.el (elisp--preceding-sexp): Skip over named character literals. * test/lisp/progmodes/elisp-mode-tests.el (elisp--preceding-sexp--char-name): Add test for skipping over named character literals (bug#23354). Copyright-paperwork-exempt: yes
-rw-r--r--lisp/progmodes/elisp-mode.el11
-rw-r--r--test/lisp/progmodes/elisp-mode-tests.el6
2 files changed, 17 insertions, 0 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index ca85980c28e..1c728484ab5 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1051,6 +1051,17 @@ If CHAR is not a character, return nil."
1051 ((or (eq (following-char) ?\') 1051 ((or (eq (following-char) ?\')
1052 (eq (preceding-char) ?\')) 1052 (eq (preceding-char) ?\'))
1053 (setq left-quote ?\`))) 1053 (setq left-quote ?\`)))
1054
1055 ;; When after a named character literal, skip over the entire
1056 ;; literal, not only its last word.
1057 (when (= (preceding-char) ?})
1058 (let ((begin (save-excursion
1059 (backward-char)
1060 (skip-syntax-backward "w-")
1061 (backward-char 3)
1062 (when (looking-at-p "\\\\N{") (point)))))
1063 (when begin (goto-char begin))))
1064
1054 (forward-sexp -1) 1065 (forward-sexp -1)
1055 ;; If we were after `?\e' (or similar case), 1066 ;; If we were after `?\e' (or similar case),
1056 ;; use the whole thing, not just the `e'. 1067 ;; use the whole thing, not just the `e'.
diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el
index 1679af30821..a7562a00c88 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -641,5 +641,11 @@ to (xref-elisp-test-descr-to-target xref)."
641 (elisp--xref-find-definitions (eval '(provide 'stephe-leake-feature))) 641 (elisp--xref-find-definitions (eval '(provide 'stephe-leake-feature)))
642 nil) 642 nil)
643 643
644(ert-deftest elisp--preceding-sexp--char-name ()
645 (with-temp-buffer
646 (emacs-lisp-mode)
647 (insert "?\\N{HEAVY CHECK MARK}")
648 (should (equal (elisp--preceding-sexp) ?\N{HEAVY CHECK MARK}))))
649
644(provide 'elisp-mode-tests) 650(provide 'elisp-mode-tests)
645;;; elisp-mode-tests.el ends here 651;;; elisp-mode-tests.el ends here