From fa87c4cf8a62d37b71e62f4b007d8a8cc43895cf Mon Sep 17 00:00:00 2001 From: Shakthi Kannan Date: Thu, 17 Dec 2015 22:25:14 +0530 Subject: [PATCH] Document Lisp mode fontification for strings after documentation --- doc/emacs/display.texi | 5 +++++ etc/NEWS | 5 +++++ lisp/emacs-lisp/lisp-mode.el | 3 +++ 3 files changed, 13 insertions(+) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index a722ec4..73a5112 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -867,6 +867,11 @@ any string or comment. Therefore, you should avoid placing an open-parenthesis or open-brace in the leftmost column, if it is inside a string or comment. @xref{Left Margin Paren}, for details. +@findex lisp-mode + Documentation of the form (:documentation ``the doc string'') now +support fontification in Lisp mode. These forms are used in Common +Lisp code for CLOS class and slot documentation. + @findex font-lock-add-keywords Font Lock highlighting patterns already exist for most modes, but you may want to fontify additional patterns. You can use the function diff --git a/etc/NEWS b/etc/NEWS index 2788f5c..2e0ea44 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -631,7 +631,12 @@ respectively, `show-paren-when-point-inside-paren' or `show-paren-when-point-in-periphery'. ** Lisp mode + ++++ *** Strings after `:documentation' are highlighted as docstrings. +This enhances Lisp mode fontification to handle documentation of the +form (:documentation "the doc string") used in Common Lisp code for +CLOS class and slot documentation. ** Rectangle editing *** Rectangle Mark mode can have corners past EOL or in the middle of a TAB. diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 9ce0dfd..446afb5 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -486,6 +486,7 @@ This will generate compile-time constants from BINDINGS." "Default expressions to highlight in Lisp modes.") (defun lisp-string-in-doc-position-p (listbeg startpos) + "Returns true if Lisp string is in docstring position" (let* ((firstsym (and listbeg (save-excursion (goto-char listbeg) @@ -516,6 +517,7 @@ This will generate compile-time constants from BINDINGS." (= (point) startpos)))))) (defun lisp-string-after-doc-keyword-p (listbeg startpos) + "Returns true if Lisp string contains :documentation" (and listbeg ; We are inside a Lisp form. (save-excursion (goto-char startpos) @@ -524,6 +526,7 @@ This will generate compile-time constants from BINDINGS." (looking-at ":documentation\\_>")))))) (defun lisp-font-lock-syntactic-face-function (state) + "Font lock a string after :documentation" (if (nth 3 state) ;; This might be a (doc)string or a |...| symbol. (let ((startpos (nth 8 state))) -- 2.1.4