unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1744: bug-reference-mode doesn't fontify when called from mode hook
@ 2008-12-30 23:44 ` Juri Linkov
  2009-01-09  1:48   ` Glenn Morris
  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
  0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2008-12-30 23:44 UTC (permalink / raw)
  To: emacs-pretest-bug

With the following mode hook:

  (add-hook 'change-log-mode-hook 'bug-reference-mode)

and a file local variable `bug-reference-url-format'
in the ChangeLog file:

;; Local Variables:
;; bug-reference-url-format: "http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=%s"
;; End:

bug references never get fontified because `bug-reference-mode' tests
whether a variable `bug-reference-url-format' is non-nil before calling
`(jit-lock-register #'bug-reference-fontify)' in `bug-reference-mode',
and this variable is not yet set because it gets initialized later
in `hack-local-variables' called after `set-auto-mode' in `normal-mode'.

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#1744: bug-reference-mode doesn't fontify when called from mode hook
  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
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Glenn Morris @ 2009-01-09  1:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 1744

Juri Linkov wrote:

>   (add-hook 'change-log-mode-hook 'bug-reference-mode)
>
> and a file local variable `bug-reference-url-format'
> in the ChangeLog file:
[...]
> bug references never get fontified because `bug-reference-mode' tests
> whether a variable `bug-reference-url-format' is non-nil before calling
> `(jit-lock-register #'bug-reference-fontify)' in `bug-reference-mode',
> and this variable is not yet set because it gets initialized later
> in `hack-local-variables' called after `set-auto-mode' in `normal-mode'.


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))
  	(when bug-reference-url-format
! 	  (jit-lock-register #'bug-reference-fontify)))
      (jit-lock-unregister #'bug-reference-fontify)
      (save-restriction
        (widen)






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#1744: bug-reference-mode doesn't fontify when called from mode hook
  2009-01-09  1:48   ` Glenn Morris
@ 2009-01-12  0:57     ` Juri Linkov
  2009-01-12  1:36       ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2009-01-12  0:57 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1744

> 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/






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#1744: bug-reference-mode doesn't fontify when called from mode hook
  2009-01-12  0:57     ` Juri Linkov
@ 2009-01-12  1:36       ` Glenn Morris
  2009-01-12 21:06         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Glenn Morris @ 2009-01-12  1:36 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 1744

Juri Linkov wrote:

> I propose a simpler solution

Fine by me.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#1744: bug-reference-mode doesn't fontify when called from mode hook
  2009-01-12  1:36       ` Glenn Morris
@ 2009-01-12 21:06         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-01-12 21:06 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1744

> Juri Linkov wrote:
>> I propose a simpler solution

Yes, that's a good solution, thanks.


        Stefan







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#1744: marked as done (bug-reference-mode doesn't fontify when called from mode hook)
  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-14  0:50   ` Emacs bug Tracking System
  1 sibling, 0 replies; 6+ messages in thread
From: Emacs bug Tracking System @ 2009-01-14  0:50 UTC (permalink / raw)
  To: Juri Linkov

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]


Your message dated Wed, 14 Jan 2009 02:44:32 +0200
with message-id <87vdsiaf7z.fsf@jurta.org>
and subject line Re: bug#1744: bug-reference-mode doesn't fontify when called from mode hook
has caused the Emacs bug report #1744,
regarding bug-reference-mode doesn't fontify when called from mode hook
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
1744: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1744
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 3277 bytes --]

From: Juri Linkov <juri@jurta.org>
To: emacs-pretest-bug@gnu.org
Subject: bug-reference-mode doesn't fontify when called from mode hook
Date: Wed, 31 Dec 2008 01:44:21 +0200
Message-ID: <877i5hfctm.fsf@jurta.org>

With the following mode hook:

  (add-hook 'change-log-mode-hook 'bug-reference-mode)

and a file local variable `bug-reference-url-format'
in the ChangeLog file:

;; Local Variables:
;; bug-reference-url-format: "http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=%s"
;; End:

bug references never get fontified because `bug-reference-mode' tests
whether a variable `bug-reference-url-format' is non-nil before calling
`(jit-lock-register #'bug-reference-fontify)' in `bug-reference-mode',
and this variable is not yet set because it gets initialized later
in `hack-local-variables' called after `set-auto-mode' in `normal-mode'.

-- 
Juri Linkov
http://www.jurta.org/emacs/



[-- Attachment #3: Type: message/rfc822, Size: 1730 bytes --]

From: Juri Linkov <juri@jurta.org>
To: 1744-done@emacsbugs.donarmstrong.com
Subject: Re: bug#1744: bug-reference-mode doesn't fontify when called from mode hook
Date: Wed, 14 Jan 2009 02:44:32 +0200
Message-ID: <87vdsiaf7z.fsf@jurta.org>

Fixed.

-- 
Juri Linkov
http://www.jurta.org/emacs/


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-01-14  0:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).