From 28a9a0390ec8e05c732410f0b0678466a7280b16 Mon Sep 17 00:00:00 2001 From: Shakthi Kannan Date: Wed, 30 Dec 2015 11:50:20 +0530 Subject: [PATCH] Document Lisp mode fontification for strings after documentation --- etc/NEWS | 5 +++++ lisp/emacs-lisp/lisp-mode.el | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 2788f5c..2f33cdb 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..231b33f 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -486,6 +486,9 @@ lisp-cl-font-lock-keywords "Default expressions to highlight in Lisp modes.") (defun lisp-string-in-doc-position-p (listbeg startpos) + "Return true if STARTPOS is a position inside a list where a +docstring may occur. LISTBEG is the position of the start of the +innermost list containing STARTPOS." (let* ((firstsym (and listbeg (save-excursion (goto-char listbeg) @@ -516,6 +519,9 @@ lisp-string-in-doc-position-p (= (point) startpos)))))) (defun lisp-string-after-doc-keyword-p (listbeg startpos) + "Return true if STARTPOS is a position inside a list right +after a :documentation symbol. LISTBEG is the position of the +start of the innermost list containing STARTPOS." (and listbeg ; We are inside a Lisp form. (save-excursion (goto-char startpos) @@ -524,6 +530,8 @@ lisp-string-after-doc-keyword-p (looking-at ":documentation\\_>")))))) (defun lisp-font-lock-syntactic-face-function (state) + "Return the Lisp font lock syntactic face function for the +position represented by STATE, a `parse-partial-sexp' state." (if (nth 3 state) ;; This might be a (doc)string or a |...| symbol. (let ((startpos (nth 8 state))) -- 2.1.4