From bcb6c7b7cd954fc653fe54c20aa4a5d8dd97d76d Mon Sep 17 00:00:00 2001 From: Graham Dobbins Date: Sun, 19 Mar 2017 21:06:18 -0400 Subject: * lisp/emacs-lisp/lisp-mode.el (indent-sexp): Fix null endpos case Copyright-paperwork-exempt: yes --- lisp/emacs-lisp/lisp-mode.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index eb07c18b03d..d6293c03040 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1083,7 +1083,8 @@ ENDPOS is encountered." (init-depth (car state)) (next-depth init-depth) (last-depth init-depth) - (last-syntax-point (point))) + (last-syntax-point (point)) + (real-endpos endpos)) (unless endpos ;; Get error now if we don't have a complete sexp after point. (save-excursion (forward-sexp 1) @@ -1116,6 +1117,8 @@ ENDPOS is encountered." last-depth (- last-depth next-depth) next-depth init-depth)) (forward-line 1) + (when (and (not real-endpos) (<= next-depth init-depth)) + (goto-char endpos)) (when (< (point) endpos) (let ((depth-delta (- next-depth last-depth))) (cond ((< depth-delta 0) -- cgit v1.2.3 From e69a5f5e456b39ad37f7d622386063548bea8208 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 24 Mar 2017 09:39:34 -0400 Subject: * lisp/emacs-lisp/lisp-mode.el: Don't highlight \( at BOL (elisp--font-lock-backslash): Extract from lisp-el-font-lock-keywords-2. Don't highlight \ at BOL. Don't assume syntax-ppss preserves match-data. --- lisp/emacs-lisp/lisp-mode.el | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d6293c03040..b7a5eb774da 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -259,6 +259,24 @@ This will generate compile-time constants from BINDINGS." (funcall loop bindings))))))) (funcall loop bindings))) +(defun elisp--font-lock-backslash () + (let* ((beg0 (match-beginning 0)) + (end0 (match-end 0)) + (ppss (save-excursion (syntax-ppss beg0)))) + (and (nth 3 ppss) ;Inside a string. + (not (nth 5 ppss)) ;The \ is not itself \-escaped. + ;; Don't highlight the \( introduced because of + ;; `open-paren-in-column-0-is-defun-start'. + (not (eq ?\n (char-before beg0))) + (equal (ignore-errors + (car (read-from-string + (format "\"%s\"" + (buffer-substring-no-properties + beg0 end0))))) + (buffer-substring-no-properties (1+ beg0) end0)) + `(face ,font-lock-warning-face + help-echo "This \\ has no effect")))) + (let-when-compile ((lisp-fdefs '("defmacro" "defun")) (lisp-vdefs '("defvar")) @@ -413,17 +431,7 @@ This will generate compile-time constants from BINDINGS." (1 font-lock-constant-face prepend)) ;; Ineffective backslashes (typically in need of doubling). ("\\(\\\\\\)\\([^\"\\]\\)" - (1 (let ((ppss (save-excursion (syntax-ppss (match-beginning 0))))) - (and (nth 3 ppss) ;Inside a string. - (not (nth 5 ppss)) ;The \ is not itself \-escaped. - (equal (ignore-errors - (car (read-from-string - (format "\"%s\"" - (match-string-no-properties 0))))) - (match-string-no-properties 2)) - `(face ,font-lock-warning-face - help-echo "This \\ has no effect"))) - prepend)) + (1 (elisp--font-lock-backslash) prepend)) ;; Words inside ‘’ and `' tend to be symbol names. (,(concat "[`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)" lisp-mode-symbol-regexp "\\)['’]") -- cgit v1.2.3