unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
@ 2004-06-22 19:26 Francis Litterio
  2004-06-22 23:19 ` Juri Linkov
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Francis Litterio @ 2004-06-22 19:26 UTC (permalink / raw)


This patch to lisp/progmodes/compile.el in the CVS Emacs sources allows
compilation-next-error-function to either highlight the displayed line
of code for a configurable amount of time (it used to be hard-coded at
0.5 seconds) or to leave it highlighted until the next command is
entered.

I hope this change is of value.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.


--- compile.el	09 Jun 2004 13:15:22 -0400	1.321
+++ compile.el	22 Jun 2004 15:25:41 -0400	
@@ -375,6 +375,16 @@
 (defvar compilation-highlight-overlay nil
   "Overlay used to temporarily highlight compilation matches.")
 
+(defcustom compilation-highlight-duration 0.5
+  "*If the value of this variable is a number, it specifies the
+number of seconds that the text highlighted by
+compilation-next-error-function will be highlighted.  If the
+value of this variable is not a number (e.g., a symbol, such as
+nil or t), then the text remains highlighted until the next
+command occurs."
+  :type 'integer
+  :group 'compilation)
+
 (defcustom compilation-error-screen-columns t
   "*If non-nil, column numbers in error messages are screen columns.
 Otherwise they are interpreted as character positions, with
@@ -1518,6 +1528,12 @@
                             (point))))
   (set-window-point w mk))
 
+(defun compilation-delete-overlay ()
+  "Deletes the overlay stored in compilation-highlight-overlay
+and removes this function from pre-command-hook."
+  (delete-overlay compilation-highlight-overlay)
+  (remove-hook 'pre-command-hook 'compilation-delete-overlay 'local))
+
 (defun compilation-goto-locus (msg mk end-mk)
   "Jump to an error corresponding to MSG at MK.
 All arguments are markers.  If END-MK is non nil, mark is set there."
@@ -1574,8 +1590,11 @@
 		  (goto-char (match-beginning 0))
 		  (move-overlay compilation-highlight-overlay (match-beginning 0) (match-end 0)))
 	      (move-overlay compilation-highlight-overlay (point) end))
-	    (sit-for 0.5)
-	    (delete-overlay compilation-highlight-overlay)))))))
+	    (if (numberp compilation-highlight-duration)
+		(progn
+		  (sit-for compilation-highlight-duration)
+		  (delete-overlay compilation-highlight-overlay))
+	      (add-hook 'pre-command-hook 'compilation-delete-overlay nil 'local))))))))
 
 \f
 (defun compilation-find-file (marker filename dir &rest formats)

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-22 19:26 [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed Francis Litterio
@ 2004-06-22 23:19 ` Juri Linkov
  2004-06-23  4:50 ` Eli Zaretskii
  2004-06-28 14:58 ` Richard Stallman
  2 siblings, 0 replies; 13+ messages in thread
From: Juri Linkov @ 2004-06-22 23:19 UTC (permalink / raw)
  Cc: emacs-devel

Francis Litterio <franl@world.std.com> writes:
> This patch to lisp/progmodes/compile.el in the CVS Emacs sources allows
> compilation-next-error-function to either highlight the displayed line
> of code for a configurable amount of time (it used to be hard-coded at
> 0.5 seconds) or to leave it highlighted until the next command is
> entered.
>
> I hope this change is of value.

A similar change was discussed recently but was stuck with naming
of this option: it should be used by packages other than compile
(grep, diff, occur, ...), but neither `compilation-highlight' nor
`next-error-highlight' seems right when applied to non-compilation
buffers.  Perhaps `locus-highlight' or `match-highlight' are better
names.

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

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-22 19:26 [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed Francis Litterio
  2004-06-22 23:19 ` Juri Linkov
@ 2004-06-23  4:50 ` Eli Zaretskii
  2004-06-28 14:58 ` Richard Stallman
  2 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2004-06-23  4:50 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Tue, 22 Jun 2004 15:26:28 -0400
> From: Francis Litterio <franl@world.std.com>
> 
> +(defcustom compilation-highlight-duration 0.5
> +  "*If the value of this variable is a number, it specifies the
> +number of seconds that the text highlighted by
> +compilation-next-error-function will be highlighted.  If the
> +value of this variable is not a number (e.g., a symbol, such as
> +nil or t), then the text remains highlighted until the next
> +command occurs."

I think a value of nil should do something more intuitive, like
disable highlighting altogether.

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-22 19:26 [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed Francis Litterio
  2004-06-22 23:19 ` Juri Linkov
  2004-06-23  4:50 ` Eli Zaretskii
@ 2004-06-28 14:58 ` Richard Stallman
  2004-06-29  1:32   ` Juri Linkov
  2 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2004-06-28 14:58 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov responded:

    A similar change was discussed recently but was stuck with naming
    of this option: it should be used by packages other than compile
    (grep, diff, occur, ...), but neither `compilation-highlight' nor
    `next-error-highlight' seems right when applied to non-compilation
    buffers.

As long as the command is called `next-error', it is ok to call some
related thing `next-error-highlight'.  Even the name
`compilation-highlight-duration' can't be objected to, given that the
function that would use it is called `compilation-goto-locus'.
We might consider a change in all these names, but that is a separate
issue.  There is no need to hold up this little feature for that.

ISTR that we already discussed some other feature for highlighting
the source code line.  What is actually installed now?

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-28 14:58 ` Richard Stallman
@ 2004-06-29  1:32   ` Juri Linkov
  2004-06-30  3:02     ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Juri Linkov @ 2004-06-29  1:32 UTC (permalink / raw)
  Cc: Francis Litterio, emacs-devel

Richard Stallman <rms@gnu.org> writes:
> Juri Linkov responded:
>     A similar change was discussed recently but was stuck with naming
>     of this option: it should be used by packages other than compile
>     (grep, diff, occur, ...), but neither `compilation-highlight' nor
>     `next-error-highlight' seems right when applied to non-compilation
>     buffers.
>
> As long as the command is called `next-error', it is ok to call some
> related thing `next-error-highlight'.

The command `next-error' already has two aliases: `goto-next-locus'
and `next-match'.  Should we make aliases for new options, faces and
customization group?

> Even the name `compilation-highlight-duration' can't be objected to,
> given that the function that would use it is called
> `compilation-goto-locus'.

If it is used only in `compilation-goto-locus' the option name
`compilation-highlight-duration' is still not right for grep commands
which use compile.el.

> We might consider a change in all these names, but that is a
> separate issue.  There is no need to hold up this little feature for
> that.

It's better to resolve the naming issue now than to make the option
name obsolete after the next release when a better name will be proposed.

> ISTR that we already discussed some other feature for highlighting
> the source code line.  What is actually installed now?

Nothing was installed yet.  The proposed patch was like below:

Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.648
diff -u -r1.648 simple.el
--- lisp/simple.el	13 Jun 2004 22:00:17 -0000	1.648
+++ lisp/simple.el	29 Jun 2004 02:33:55 -0000
@@ -200,7 +207,8 @@
 Finds and highlights the source line like \\[next-error], but does not
 select the source buffer."
   (interactive "p")
-  (next-error n)
+  (let ((next-error-highlight next-error-highlight-no-select))
+    (next-error n))
   (pop-to-buffer next-error-last-buffer))
 
 (defun previous-error-no-select (n)
@@ -212,6 +220,44 @@
   (interactive "p")
   (next-error-no-select (- n)))
 
+(defgroup next-error nil
+  "next-error support framework."
+  :group 'tools)
+
+(defface next-error
+  '((t (:inherit region)))
+  "Face used to highlight next error locus."
+  :group 'next-error
+  :version "21.4")
+(defvar next-error-face 'next-error
+  "Face name used to highlight next error locus.")
+
+(defcustom next-error-highlight 0.1
+  "*Highlighting method in selected buffers.
+If number highlight the locus in next-error face for given time in seconds.
+If t, use persistent overlays fontified in next-error face.
+If nil, don't highlight the locus in the source buffer.
+If `fringe-arrow', indicate the locus by the fringe arrow."
+  :type '(choice (integer :tag "Delay")
+                 (const :tag "Persistent overlay" t)
+		 (const :tag "No highlighting" nil)
+		 (const :tag "Fringe arrow" 'fringe-arrow))
+  :group 'compilation
+  :version "21.4")
+
+(defcustom next-error-highlight-no-select 0.1
+  "*Highlighting method in non-selected buffers.
+If number, highlight the locus in next-error face for given time in seconds.
+If t, use persistent overlays fontified in next-error face.
+If nil, don't highlight the locus in the source buffer.
+If `fringe-arrow', indicate the locus by the fringe arrow."
+  :type '(choice (integer :tag "Delay")
+                 (const :tag "Persistent overlay" t)
+		 (const :tag "No highlighting" nil)
+		 (const :tag "Fringe arrow" 'fringe-arrow))
+  :group 'compilation
+  :version "21.4")
+\f
 ;;;
 
 (defun fundamental-mode ()

Index: lisp/progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.322
diff -u -r1.322 compile.el
--- lisp/progmodes/compile.el	18 Jun 2004 23:00:46 -0000	1.322
+++ lisp/progmodes/compile.el	29 Jun 2004 02:35:35 -0000
@@ -1562,7 +1569,7 @@
       (unless compilation-highlight-overlay
 	(setq compilation-highlight-overlay
 	      (make-overlay (point-min) (point-min)))
-	(overlay-put compilation-highlight-overlay 'face 'region))
+	(overlay-put compilation-highlight-overlay 'face next-error-face))
       (with-current-buffer (marker-buffer mk)
 	(save-excursion
 	  (end-of-line)
@@ -1572,11 +1579,17 @@
 		     (re-search-forward highlight-regexp end t))
 		(progn
 		  (goto-char (match-beginning 0))
-		  (move-overlay compilation-highlight-overlay (match-beginning 0) (match-end 0)))
-	      (move-overlay compilation-highlight-overlay (point) end))
-	    (sit-for 0.5)
-	    (delete-overlay compilation-highlight-overlay)))))))
-
+		  (move-overlay compilation-highlight-overlay
+                                (match-beginning 0) (match-end 0) (current-buffer)))
+	      (move-overlay compilation-highlight-overlay
+                            (point) end (current-buffer)))
+	    (if (numberp next-error-highlight)
+                (sit-for next-error-highlight))
+	    (if (not (eq next-error-highlight t))
+                (delete-overlay compilation-highlight-overlay))))))
+    (when (and (eq next-error-highlight 'fringe-arrow))
+      (set (make-local-variable 'overlay-arrow-position)
+           (copy-marker (line-beginning-position))))))
 \f
 (defun compilation-find-file (marker filename dir &rest formats)
   "Find a buffer for file FILENAME.

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

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-29  1:32   ` Juri Linkov
@ 2004-06-30  3:02     ` Richard Stallman
  2004-07-01  5:46       ` Juri Linkov
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2004-06-30  3:02 UTC (permalink / raw)
  Cc: franl, emacs-devel

As long as the command name on C-x ` is next-error, we may as well
call the option next-error-highlight.  If we change that binding
before the release, we can rename the option at the same time.

So please install this, as soon as you've written the changes for
etc/NEWS and the Emacs Manual.

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-06-30  3:02     ` Richard Stallman
@ 2004-07-01  5:46       ` Juri Linkov
  2004-07-02 10:12         ` Richard Stallman
  2004-07-10 22:41         ` Richard Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: Juri Linkov @ 2004-07-01  5:46 UTC (permalink / raw)
  Cc: tzz, emacs-devel

Richard Stallman <rms@gnu.org> writes:
> As long as the command name on C-x ` is next-error, we may as well
> call the option next-error-highlight.  If we change that binding
> before the release, we can rename the option at the same time.
>
> So please install this, as soon as you've written the changes for
> etc/NEWS and the Emacs Manual.

Mentioning the changes in etc/NEWS is ok, but I can't find a place in
the Emacs Manual where new options `next-error-highlight' and
`next-error-highlight-no-select' should be documented.

I recall that documentation rules disapprove adding every option
to the manual to not make it too big.  And it seems these options are
not too significant for using `next-error' to justify their additions
to the manual.

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

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-07-01  5:46       ` Juri Linkov
@ 2004-07-02 10:12         ` Richard Stallman
  2004-07-10 22:41         ` Richard Stallman
  1 sibling, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2004-07-02 10:12 UTC (permalink / raw)
  Cc: tzz, emacs-devel

    Mentioning the changes in etc/NEWS is ok, but I can't find a place in
    the Emacs Manual where new options `next-error-highlight' and
    `next-error-highlight-no-select' should be documented.

It would be in the node Compilation Mode, in building.texi, if
anywhere.  But maybe they are not important enough to be mentioned in
the manual.  I am not insisting.


The first 4 nodes in building.texi need to be thoroughly reviewed
for obsolete statements and for other important things that should
be added.  Can someone thoroughly familiar with the new compilation
code volunteer to do that?

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-07-01  5:46       ` Juri Linkov
  2004-07-02 10:12         ` Richard Stallman
@ 2004-07-10 22:41         ` Richard Stallman
  2004-07-12 16:13           ` Ted Zlatanov
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2004-07-10 22:41 UTC (permalink / raw)
  Cc: tzz, emacs-devel

[I sent this message a week ago but did not get a response.
Could we get the discussion moving again?]

The first 4 nodes in building.texi need to be thoroughly reviewed
for obsolete statements and for other important things that should
be added.  Can someone thoroughly familiar with the new compilation
code volunteer to do that?

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-07-10 22:41         ` Richard Stallman
@ 2004-07-12 16:13           ` Ted Zlatanov
  2004-07-14  0:16             ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Ted Zlatanov @ 2004-07-12 16:13 UTC (permalink / raw)


On Sat, 10 Jul 2004, rms@gnu.org wrote:

> [I sent this message a week ago but did not get a response.
> Could we get the discussion moving again?]
> 
> The first 4 nodes in building.texi need to be thoroughly reviewed
> for obsolete statements and for other important things that should
> be added.  Can someone thoroughly familiar with the new compilation
> code volunteer to do that?

Sorry, I thought "new compilation code" referred to the other major
changes in compile.el that were put in CVS.

I will look at building.texi and see if the next-error changes I did
affect anything.

Ted

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-07-12 16:13           ` Ted Zlatanov
@ 2004-07-14  0:16             ` Richard Stallman
  2004-09-13 17:58               ` Ted Zlatanov
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2004-07-14  0:16 UTC (permalink / raw)
  Cc: emacs-devel

    > The first 4 nodes in building.texi need to be thoroughly reviewed
    > for obsolete statements and for other important things that should
    > be added.  Can someone thoroughly familiar with the new compilation
    > code volunteer to do that?

    Sorry, I thought "new compilation code" referred to the other major
    changes in compile.el that were put in CVS.

    I will look at building.texi and see if the next-error changes I did
    affect anything.

All the changes in compile.el, including Daniel Pfeiffer's, could
require changes in the manual.  If you reread the NEWS and you're
familiar with the code as it stands now, you could probably
recognize whatever errors there may be in the manual.  That would
be quite useful.

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-07-14  0:16             ` Richard Stallman
@ 2004-09-13 17:58               ` Ted Zlatanov
  2004-09-17  9:36                 ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Ted Zlatanov @ 2004-09-13 17:58 UTC (permalink / raw)
  Cc: emacs-devel

On Tue, 13 Jul 2004, rms@gnu.org wrote:

> All the changes in compile.el, including Daniel Pfeiffer's, could
> require changes in the manual.  If you reread the NEWS and you're
> familiar with the code as it stands now, you could probably
> recognize whatever errors there may be in the manual.  That would
> be quite useful.

I looked through the current building.texi manual and it appears to be
accurate.  The major changes don't affect anything that was already
documented (AFAIK).  They add features, mostly, or enhance existing
ones.  compilation-environment might need a mention in the manual.

Ted

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

* Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
  2004-09-13 17:58               ` Ted Zlatanov
@ 2004-09-17  9:36                 ` Richard Stallman
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2004-09-17  9:36 UTC (permalink / raw)
  Cc: emacs-devel

Thanks for checking building.texi.
I will add something about compilation-environment.

If you would like to read and check some additional files, that would
be very useful.

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

end of thread, other threads:[~2004-09-17  9:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-22 19:26 [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed Francis Litterio
2004-06-22 23:19 ` Juri Linkov
2004-06-23  4:50 ` Eli Zaretskii
2004-06-28 14:58 ` Richard Stallman
2004-06-29  1:32   ` Juri Linkov
2004-06-30  3:02     ` Richard Stallman
2004-07-01  5:46       ` Juri Linkov
2004-07-02 10:12         ` Richard Stallman
2004-07-10 22:41         ` Richard Stallman
2004-07-12 16:13           ` Ted Zlatanov
2004-07-14  0:16             ` Richard Stallman
2004-09-13 17:58               ` Ted Zlatanov
2004-09-17  9:36                 ` Richard Stallman

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).