From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] Update package: psgml Date: Mon, 17 Apr 2017 12:34:18 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1492446882 9992 195.159.176.226 (17 Apr 2017 16:34:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Apr 2017 16:34:42 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: Lucien Pullen To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 17 18:34:36 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d09bn-0002Rz-Iw for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2017 18:34:35 +0200 Original-Received: from localhost ([::1]:37767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d09br-0006y5-V8 for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2017 12:34:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d09bi-0006w5-Rs for emacs-devel@gnu.org; Mon, 17 Apr 2017 12:34:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d09bf-0002Va-Os for emacs-devel@gnu.org; Mon, 17 Apr 2017 12:34:30 -0400 Original-Received: from [195.159.176.226] (port=49904 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d09bf-0002VC-IE for emacs-devel@gnu.org; Mon, 17 Apr 2017 12:34:27 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1d09bX-000298-Gv for emacs-devel@gnu.org; Mon, 17 Apr 2017 18:34:19 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 91 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:4/i9Ae34rW62ZCTqDDfbRvDvK2w= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214075 Archived-At: > Update how PSGML uses `sgml-set-face' to include a list of major modes. > If the current major mode isn't in the list, treat as nil, otherwise t. > This allows PSGML's parser to be used in other major modes without > clobbering font locking in the process. Hmm.. I like the goal, but I don't like lists of major-modes. Could you give some further details about the context where you bumped into the problem? Any reason why you couldn't set sgml-set-face to nil buffer-locally instead? Stefan > From c3cf6728d7f4bb1836aefaa78c8eb3e74f722085 Mon Sep 17 00:00:00 2001 > From: Lucien Pullen > Date: Sun, 16 Apr 2017 16:00:23 -0600 > Subject: [PATCH] psgml: conditionally set face from major mode > * psgml-parse.el (sgml-set-face): In addition to never (nil) and > always (t), can be a list of major mode functions to only set face in > those modes. > --- > psgml-parse.el | 12 +++++++----- > psgml.el | 4 +++- > 2 files changed, 10 insertions(+), 6 deletions(-) > diff --git a/psgml-parse.el b/psgml-parse.el > index 5609767..eb9828e 100644 > --- a/psgml-parse.el > +++ b/psgml-parse.el > @@ -1317,8 +1317,9 @@ was successful or nil if failed." > "Set the type of the markup parsed to TYPE. > The markup starts at position given by variable `sgml-markup-start' and > ends at point." > - (when (and sgml-set-face > - (null sgml-current-eref)) > + (when (and (or (eq sgml-set-face t) > + (find major-mode sgml-set-face)) > + (null sgml-current-eref)) > (sgml-set-face-for sgml-markup-start (point) type)) > (setq sgml-markup-type type)) > @@ -2821,7 +2822,7 @@ overrides the entity type in entity look up." > (when (and (not executing-macro) > (or (and (boundp 'which-function-mode) > which-function-mode ) > - sgml-set-face) > + (or (eq sgml-set-face t) (find major-mode sgml-set-face)) > sgml-buffer-parse-state > (sit-for 0)) > (let ((deactivate-mark nil)) > @@ -2833,7 +2834,8 @@ overrides the entity type in entity look up." > (sgml-element-gi sgml-last-element))) > (let ((eol-pos (save-excursion (end-of-line 1) (point)))) > ;; Set face on current line > - (when (and sgml-set-face (not (input-pending-p))) > + (when (and (or (eq sgml-set-face t) (find major-mode sgml-set-face)) > + (not (input-pending-p))) > (save-excursion > (condition-case nil > (sgml-parse-to > @@ -2846,7 +2848,7 @@ overrides the entity type in entity look up." > (defun sgml-fontify-buffer (delay) > (and > - sgml-set-face > + (or (eq sgml-set-face t) (find major-mode sgml-set-face)) > (null (sgml-tree-etag-epos > (sgml-pstate-top-tree sgml-buffer-parse-state))) > (sit-for delay) > diff --git a/psgml.el b/psgml.el > index 142079a..b0ff140 100644 > --- a/psgml.el > +++ b/psgml.el > @@ -849,7 +849,9 @@ sgml-normalize-trims If non-nil, sgml-normalize will trim off white space > from end of element when adding end tag. > sgml-indent-step How much to increment indent for every element level. > sgml-indent-data If non-nil, indent in data/mixed context also. > -sgml-set-face If non-nil, psgml will set the face of parsed markup. > +sgml-set-face If non-nil, psgml will set the face of parsed markup, > + either always (when t) or when the buffer's major mode matches > + one of the listed function names. > sgml-markup-faces The faces used when the above variable is non-nil. > sgml-public-map Mapping from public identifiers to file names. > sgml-offer-save If non-nil, ask about saving modified buffers before > -- > 2.3.4