emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Allow compilation-next-error-function to leave code line hig


From: Juri Linkov
Subject: Re: [PATCH] Allow compilation-next-error-function to leave code line highlighted until next command is typed
Date: Tue, 29 Jun 2004 04:32:11 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Richard Stallman <address@hidden> 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")
+
 ;;;
 
 (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))))))
 
 (defun compilation-find-file (marker filename dir &rest formats)
   "Find a buffer for file FILENAME.

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]