From 1331467910537f4d85fa842c993ef2c48ebbf749 Mon Sep 17 00:00:00 2001
From: Philipp Stephani
Date: Mon, 2 May 2016 23:58:15 +0200
Subject: [PATCH] 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
---
lisp/progmodes/elisp-mode.el | 11 +++++++++++
test/lisp/progmodes/elisp-mode-tests.el | 6 ++++++
2 files changed, 17 insertions(+)
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."
((or (eq (following-char) ?\')
(eq (preceding-char) ?\'))
(setq left-quote ?\`)))
+
+ ;; When after a named character literal, skip over the entire
+ ;; literal, not only its last word.
+ (when (= (preceding-char) ?})
+ (let ((begin (save-excursion
+ (backward-char)
+ (skip-syntax-backward "w-")
+ (backward-char 3)
+ (when (looking-at-p "\\\\N{") (point)))))
+ (when begin (goto-char begin))))
+
(forward-sexp -1)
;; If we were after `?\e' (or similar case),
;; 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)."
(elisp--xref-find-definitions (eval '(provide 'stephe-leake-feature)))
nil)
+(ert-deftest elisp--preceding-sexp--char-name ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "?\\N{HEAVY CHECK MARK}")
+ (should (equal (elisp--preceding-sexp) ?\N{HEAVY CHECK MARK}))))
+
(provide 'elisp-mode-tests)
;;; elisp-mode-tests.el ends here
--
2.39.2