]> git.eshelyaron.com Git - emacs.git/commitdiff
* etc/NEWS: New Tramp method "nc".
authorRobert Brown (tiny change) <robert.brown@gmail.com>
Thu, 19 Jun 2014 14:03:45 +0000 (10:03 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 19 Jun 2014 14:03:45 +0000 (10:03 -0400)
* lisp/emacs-lisp/lisp-mode.el (lisp-string-after-doc-keyword-p): New fun.
(lisp-string-in-doc-position-p): New function, extracted from
lisp-font-lock-syntactic-face-function.
(lisp-font-lock-syntactic-face-function): Use them.

Fixes: debbugs:9130
etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/lisp-mode.el

index bd928c253762f2de58a6da9c96422b7215fc3ab8..f9cb42e2d2bdefa4e81ffaf25be035e3efb30586 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -72,6 +72,9 @@ performance improvements when pasting large amounts of text.
 \f
 * Changes in Specialized Modes and Packages in Emacs 24.5
 
+** Lisp mode
+*** Strings after `:documentation' are highlighted as docstrings.
+
 ** Rectangle editing
 *** Rectangle Mark mode can have corners past EOL or in the middle of a TAB.
 *** C-x C-x in rectangle-mark-mode now cycles through the four corners.
index 245cf859ed392d1fb11765b46509d1991f6d35a8..af2eb9712ae30edaf46d68a0702988fa18616241 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-19  Robert Brown  <robert.brown@gmail.com>  (tiny change)
+
+       * emacs-lisp/lisp-mode.el (lisp-string-after-doc-keyword-p): New fun.
+       (lisp-string-in-doc-position-p): New function, extracted from
+       lisp-font-lock-syntactic-face-function.
+       (lisp-font-lock-syntactic-face-function): Use them (bug#9130).
+
 2014-06-19  GrĂ©goire Jadi  <daimrod@gmail.com>
 
        * net/rcirc.el (rcirc-omit-mode): Fix recenter error.  (Bug#17769)
index 18ad859e0b5772a8f8989cdc5251f6a5642d541d..31df353321a5486f80eca515d4617ba3ccaf9e74 100644 (file)
@@ -413,6 +413,41 @@ It has `lisp-mode-abbrev-table' as its parent."
 (defvar lisp-cl-font-lock-keywords lisp-cl-font-lock-keywords-1
   "Default expressions to highlight in Lisp modes.")
 
+(defun lisp-string-in-doc-position-p (listbeg startpos)
+  (let* ((firstsym (and listbeg
+                        (save-excursion
+                          (goto-char listbeg)
+                          (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)")
+                               (match-string 1)))))
+         (docelt (and firstsym
+                      (function-get (intern-soft firstsym)
+                                    lisp-doc-string-elt-property))))
+    (and docelt
+         ;; It's a string in a form that can have a docstring.
+         ;; Check whether it's in docstring position.
+         (save-excursion
+           (when (functionp docelt)
+             (goto-char (match-end 1))
+             (setq docelt (funcall docelt)))
+           (goto-char listbeg)
+           (forward-char 1)
+           (condition-case nil
+               (while (and (> docelt 0) (< (point) startpos)
+                           (progn (forward-sexp 1) t))
+                 (setq docelt (1- docelt)))
+             (error nil))
+           (and (zerop docelt) (<= (point) startpos)
+                (progn (forward-comment (point-max)) t)
+                (= (point) startpos))))))
+
+(defun lisp-string-after-doc-keyword-p (listbeg startpos)
+  (and listbeg                          ; We are inside a Lisp form.
+       (save-excursion
+         (goto-char startpos)
+         (ignore-errors
+           (progn (backward-sexp 1)
+                  (looking-at ":documentation\\_>"))))))
+
 (defun lisp-font-lock-syntactic-face-function (state)
   (if (nth 3 state)
       ;; This might be a (doc)string or a |...| symbol.
@@ -420,32 +455,9 @@ It has `lisp-mode-abbrev-table' as its parent."
         (if (eq (char-after startpos) ?|)
             ;; This is not a string, but a |...| symbol.
             nil
-          (let* ((listbeg (nth 1 state))
-                 (firstsym (and listbeg
-                                (save-excursion
-                                  (goto-char listbeg)
-                                  (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)")
-                                       (match-string 1)))))
-                 (docelt (and firstsym
-                              (function-get (intern-soft firstsym)
-                                            lisp-doc-string-elt-property))))
-            (if (and docelt
-                     ;; It's a string in a form that can have a docstring.
-                     ;; Check whether it's in docstring position.
-                     (save-excursion
-                       (when (functionp docelt)
-                         (goto-char (match-end 1))
-                         (setq docelt (funcall docelt)))
-                       (goto-char listbeg)
-                       (forward-char 1)
-                       (condition-case nil
-                           (while (and (> docelt 0) (< (point) startpos)
-                                       (progn (forward-sexp 1) t))
-                             (setq docelt (1- docelt)))
-                         (error nil))
-                       (and (zerop docelt) (<= (point) startpos)
-                            (progn (forward-comment (point-max)) t)
-                            (= (point) (nth 8 state)))))
+          (let ((listbeg (nth 1 state)))
+            (if (or (lisp-string-in-doc-position-p listbeg startpos)
+                    (lisp-string-after-doc-keyword-p listbeg startpos))
                 font-lock-doc-face
               font-lock-string-face))))
     font-lock-comment-face))