From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#10245: 23.3; handle Common Lisp :documentation strings Date: Thu, 08 Dec 2011 08:30:22 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323351086 15108 80.91.229.12 (8 Dec 2011 13:31:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Dec 2011 13:31:26 +0000 (UTC) Cc: 10245@debbugs.gnu.org To: Robert Brown Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 08 14:31:21 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RYe4G-0003HA-Nw for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Dec 2011 14:31:21 +0100 Original-Received: from localhost ([::1]:38876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYe4F-0000wu-SB for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Dec 2011 08:31:19 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYe4D-0000wn-Lf for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2011 08:31:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYe48-0002s6-IV for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2011 08:31:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYe48-0002s1-Cr for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2011 08:31:12 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RYe4v-0006Px-Fy for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2011 08:32:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Dec 2011 13:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10245 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 10245-submit@debbugs.gnu.org id=B10245.132335107624611 (code B ref 10245); Thu, 08 Dec 2011 13:32:01 +0000 Original-Received: (at 10245) by debbugs.gnu.org; 8 Dec 2011 13:31:16 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RYe4C-0006Ou-Aa for submit@debbugs.gnu.org; Thu, 08 Dec 2011 08:31:16 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RYe49-0006Ok-FQ for 10245@debbugs.gnu.org; Thu, 08 Dec 2011 08:31:14 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id pB8DUMDG017263; Thu, 8 Dec 2011 08:30:23 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 372F059403; Thu, 8 Dec 2011 08:30:22 -0500 (EST) In-Reply-To: (Robert Brown's message of "Wed, 07 Dec 2011 12:55:38 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4064=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4064> : streams <708844> : uri <1024019> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 08 Dec 2011 08:32:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:54812 Archived-At: > Several Common Lisp forms, such as defgeneric and defclass, support > documentation strings following a :documentation keyword. > Here's an example of a point class with documentation strings: > (defclass foo () > ((x :reader x :initarg :x :documentation "X coordinate") > (y :reader y :initarg :y :documentation "Y coordinate")) > (:documentation "A point in the plane")) > Emacs currently fontifies the documentation strings above using > font-lock-string-face instead of font-lock-doc-face. > The code below fixes the problem for me. It is a refactoring of > lisp-font-lock-syntactic-face-function in lisp/emacs-lisp/lisp-mode.el > with the addition of a new function to detect documentation keywords. > If lisp-font-lock-syntactic-face-function is replaced with the code > below, Emacs fontifies strings after :documentation keywords using > font-lock-doc-face. Thanks. This would be a welcomed addition, for 24.2 (24.1 is in testing already so it's too late to add such features). But I think it needs a bit of massaging first, so that this new feature is not enabled in emacs-lisp-mode. E.g. I'd maybe change lisp-font-lock-syntactic-face-function to (run-hook-with-args-until-success 'lisp-string-in-doc-position-functions state) and then add string-after-documentation-keyword-p to this hook when in Common Lisp mode. If you can provide such a thing as a patch (i.e. output of "bzr diff" or "diff -u"), that would be even better. Stefan > (defun string-in-doc-position-p (state) > (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 (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) (nth 8 state))))))) > (defun string-after-documentation-keyword-p (state) > (and (nth 1 state) ; we are inside a Lisp form > (let ((startpos (nth 8 state))) > (and startpos > (let ((ok nil) > (prevsym (save-excursion > (goto-char startpos) > (condition-case nil > (progn (backward-sexp 1) (setf ok t)) > (error nil)) > (and ok > (looking-at "\\(\\sw+\\)") > (match-string 1))))) > (equal prevsym ":documentation")))))) > (defun lisp-font-lock-syntactic-face-function (state) > (if (nth 3 state) > ;; This might be a (doc)string or a |...| symbol. > (let ((startpos (nth 8 state))) > (if (eq (char-after startpos) ?|) > ;; This is not a string, but a |...| symbol. > nil > (if (or (string-in-doc-position-p state) > (string-after-documentation-keyword-p state)) > font-lock-doc-face > font-lock-string-face))) > font-lock-comment-face)) > In GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu) > of 2011-07-15 on paradicsom.nyc.corp.google.com > configured using `configure '--prefix' '/local/software/package/emacs-23.3.1' '--without-x'' > Important settings: > value of $LC_ALL: nil > value of $LC_COLLATE: nil > value of $LC_CTYPE: nil > value of $LC_MESSAGES: nil > value of $LC_MONETARY: nil > value of $LC_NUMERIC: nil > value of $LC_TIME: nil > value of $LANG: en_US.UTF-8 > value of $XMODIFIERS: nil > locale-coding-system: utf-8-unix > default enable-multibyte-characters: t > Major mode: Lisp Interaction > Minor modes in effect: > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > Recent input: > ESC [ > 1 ; 2 3 0 5 ; 0 c ESC x b u g - TAB ESC DEL > ESC DEL r e p o r t - TAB RET > Recent messages: > ("emacs") > Loading /local/software/source-trees/emacs-jabber/jabber-autoloads.el (source)...done > Load-path shadows: > /local/software/source-trees/cc-mode/cc-fonts hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-fonts > /local/software/source-trees/cc-mode/cc-align hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-align > /local/software/source-trees/cc-mode/cc-menus hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-menus > /local/software/source-trees/cc-mode/cc-engine hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-engine > /local/software/source-trees/cc-mode/cc-mode hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-mode > /local/software/source-trees/cc-mode/cc-awk hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-awk > /local/software/source-trees/cc-mode/cc-defs hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-defs > /local/software/source-trees/cc-mode/cc-vars hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-vars > /local/software/source-trees/cc-mode/cc-styles hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-styles > /local/software/source-trees/cc-mode/cc-bytecomp hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-bytecomp > /local/software/source-trees/cc-mode/cc-compat hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-compat > /local/software/source-trees/cc-mode/cc-cmds hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-cmds > /local/software/source-trees/cc-mode/cc-langs hides /local/software/package/emacs-23.3.1/share/emacs/23.3/lisp/progmodes/cc-langs > Features: > (shadow sort mail-extr message ecomplete rfc822 mml easymenu mml-sec > password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 > rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc > time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 > hex-util hashcash mail-utils warnings emacsbug uniquify advice help-fns > advice-preload slime-autoloads regexp-opt cl cl-19 ediff-hook vc-hooks > lisp-float-type lisp-mode register page menu-bar rfn-eshadow timer > jit-lock font-lock syntax facemenu font-core frame cham georgian > utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean > japanese hebrew greek romanian slovak czech european ethiopic indian > cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev > loaddefs button minibuffer faces cus-face files text-properties overlay > md5 base64 format env code-pages mule custom widget > hashtable-print-readable backquote make-network-process multi-tty emacs)