From: Juri Linkov <juri@jurta.org>
To: Glenn Morris <rgm@gnu.org>
Cc: 1744@emacsbugs.donarmstrong.com
Subject: bug#1744: bug-reference-mode doesn't fontify when called from mode hook
Date: Mon, 12 Jan 2009 02:57:09 +0200 [thread overview]
Message-ID: <871vv9jrmq.fsf@jurta.org> (raw)
In-Reply-To: <ag1vvdtfkj.fsf@fencepost.gnu.org> (Glenn Morris's message of "Thu, 08 Jan 2009 20:48:28 -0500")
> This reminds me a bit of bug#347. How about something like this:
>
> *** bug-reference.el 5 Jan 2009 03:23:16 -0000 1.6
> --- bug-reference.el 9 Jan 2009 01:47:30 -0000
> ***************
> *** 114,121 ****
> ""
> nil
> (if bug-reference-mode
> (when bug-reference-url-format
> ! (jit-lock-register #'bug-reference-fontify))
> (jit-lock-unregister #'bug-reference-fontify)
> (save-restriction
> (widen)
> --- 114,125 ----
> ""
> nil
> (if bug-reference-mode
> + (progn
> + (let ((enable-local-variables :safe)
> + (enable-local-eval nil))
> + (hack-local-variables))
I think it's a fairly brittle solution to deal with direct hacking
of local variables. I propose a simpler solution that postpones
checking for non-nil bug-reference-url-format in bug-reference-fontify
that gets called after bug-reference-url-format is set from the
local variables section. A good side of it is that even when
bug-reference-url-format is still not specified for the moment
of font-locking, bug numbers are still highlighted. I've verified
that the following patch works also when `mode: bug-reference' is
located before `bug-reference-url-format: "..."' in ChangeLog files:
Index: lisp/progmodes/bug-reference.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/bug-reference.el,v
retrieving revision 1.6
diff -u -w -b -r1.6 bug-reference.el
--- lisp/progmodes/bug-reference.el 5 Jan 2009 03:23:16 -0000 1.6
+++ lisp/progmodes/bug-reference.el 12 Jan 2009 00:52:15 -0000
@@ -85,9 +85,11 @@
(let ((overlay (make-overlay (match-beginning 0) (match-end 0)
nil t nil)))
(overlay-put overlay 'category 'bug-reference)
+ ;; Don't put a link if format is undefined
+ (when bug-reference-url-format
(overlay-put overlay 'bug-reference-url
(format bug-reference-url-format
- (match-string-no-properties 1)))))))))
+ (match-string-no-properties 1))))))))))
;; Taken from button.el.
(defun bug-reference-push-button (&optional pos use-mouse-action)
@@ -108,14 +110,12 @@
;;;###autoload
(define-minor-mode bug-reference-mode
- "Minor mode to buttonize bugzilla references in the current buffer.
-Requires `bug-reference-url-format' to be set in the buffer."
+ "Minor mode to buttonize bugzilla references in the current buffer."
nil
""
nil
(if bug-reference-mode
- (when bug-reference-url-format
- (jit-lock-register #'bug-reference-fontify))
+ (jit-lock-register #'bug-reference-fontify)
(jit-lock-unregister #'bug-reference-fontify)
(save-restriction
(widen)
@@ -128,8 +128,7 @@
""
nil
(if bug-reference-prog-mode
- (when bug-reference-url-format
- (jit-lock-register #'bug-reference-fontify))
+ (jit-lock-register #'bug-reference-fontify)
(jit-lock-unregister #'bug-reference-fontify)
(save-restriction
(widen)
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2009-01-12 0:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87vdsiaf7z.fsf@jurta.org>
2008-12-30 23:44 ` bug#1744: bug-reference-mode doesn't fontify when called from mode hook Juri Linkov
2009-01-09 1:48 ` Glenn Morris
2009-01-12 0:57 ` Juri Linkov [this message]
2009-01-12 1:36 ` Glenn Morris
2009-01-12 21:06 ` Stefan Monnier
2009-01-14 0:50 ` bug#1744: marked as done (bug-reference-mode doesn't fontify when called from mode hook) Emacs bug Tracking System
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871vv9jrmq.fsf@jurta.org \
--to=juri@jurta.org \
--cc=1744@emacsbugs.donarmstrong.com \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.