unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Finding the source of Change Log entries
@ 2008-07-12  9:32 martin rudalics
  2008-07-12 10:00 ` Lennart Borgman (gmail)
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: martin rudalics @ 2008-07-12  9:32 UTC (permalink / raw)
  To: emacs-devel

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

Months ago I wrote a couple of functions to find the source code
corresponding to Change Log entries.  Anyone still interested?

[-- Attachment #2: add-log.patch --]
[-- Type: text/plain, Size: 9274 bytes --]

*** add-log.el.~1.212.~	2008-06-24 06:04:48.000000000 +0200
--- add-log.el	2008-07-12 10:14:41.796875000 +0200
***************
*** 298,307 ****
  	;; name.
  	(progn
  	  (re-search-forward change-log-file-names-re nil t)
! 	  (match-string 2))
        (if (looking-at change-log-file-names-re)
  	  ;; We found a file name.
! 	  (match-string 2)
  	;; Look backwards for either a file name or the log entry start.
  	(if (re-search-backward
  	     (concat "\\(" change-log-start-entry-re 
--- 298,307 ----
  	;; name.
  	(progn
  	  (re-search-forward change-log-file-names-re nil t)
! 	  (match-string-no-properties 2))
        (if (looking-at change-log-file-names-re)
  	  ;; We found a file name.
! 	  (match-string-no-properties 2)
  	;; Look backwards for either a file name or the log entry start.
  	(if (re-search-backward
  	     (concat "\\(" change-log-start-entry-re 
***************
*** 312,322 ****
  		;; file name.
  		(progn
  		  (re-search-forward change-log-file-names-re nil t)
! 		  (match-string 2))
! 	      (match-string 4))
  	  ;; We must be before any file name, look forward.
  	  (re-search-forward change-log-file-names-re nil t)
! 	  (match-string 2))))))
  
  (defun change-log-find-file ()
    "Visit the file for the change under point."
--- 312,322 ----
  		;; file name.
  		(progn
  		  (re-search-forward change-log-file-names-re nil t)
! 		  (match-string-no-properties 2))
! 	      (match-string-no-properties 4))
  	  ;; We must be before any file name, look forward.
  	  (re-search-forward change-log-file-names-re nil t)
! 	  (match-string-no-properties 2))))))
  
  (defun change-log-find-file ()
    "Visit the file for the change under point."
***************
*** 326,336 ****
--- 326,521 ----
  	(find-file file)
        (message "No such file or directory: %s" file))))
  
+ (defun change-log-search-tag-name-1 (&optional from)
+   "Search for a tag name within subexpression 1 of last match.
+ Optional argument FROM specifies a buffer position where the tag
+ name should be located.  Return value is a cons whose car is the
+ string representing the tag and whose cdr is the position where
+ the tag was found."
+   (save-restriction
+     (narrow-to-region (match-beginning 1) (match-end 1))
+     (when from (goto-char from))
+     ;; The regexp below skips any symbol near `point' (FROM) followed by
+     ;; whitespace and another symbol.  This should skip, for example,
+     ;; "struct" in a specification like "(struct buffer)" and move to
+     ;; "buffer".  A leading paren is ignored.
+     (when (looking-at
+ 	   "[(]?\\(?:\\(?:\\sw\\|\\s_\\)+\\(?:[ \t]+\\(\\sw\\|\\s_\\)+\\)\\)")
+       (goto-char (match-beginning 1)))
+     (cons (find-tag-default) (point))))
+ 
+ (defconst change-log-tag-re
+   "(\\(\\(?:\\sw\\|\\s_\\)+\\(?:[, \t]+\\(?:\\sw\\|\\s_\\)+\\)*\\))"
+   "Regexp matching a tag name in change log entries.")
+ 
+ (defun change-log-search-tag-name (&optional at)
+   "Search for a tag name near `point'.
+ Optional argument AT non-nil means search near buffer position
+ AT.  Return value is a cons whose car is the string representing
+ the tag and whose cdr is the position where the tag was found."
+   (save-excursion
+     (goto-char (setq at (or at (point))))
+     (save-restriction
+       (widen)
+       (or (condition-case nil
+ 	      ;; Within parenthesized list?
+ 	      (save-excursion
+ 		(backward-up-list)
+ 		(when (looking-at change-log-tag-re)
+ 		  (change-log-search-tag-name-1 at)))
+ 	    (error nil))
+ 	  (condition-case nil
+ 	      ;; Before parenthesized list?
+ 	      (save-excursion
+ 		(when (and (skip-chars-forward " \t")
+ 			   (looking-at change-log-tag-re))
+ 		  (change-log-search-tag-name-1)))
+ 	    (error nil))
+ 	  (condition-case nil
+ 	      ;; Near filename?
+ 	      (save-excursion
+ 		(when (and (progn
+ 			     (beginning-of-line)
+ 			     (looking-at change-log-file-names-re))
+ 			   (goto-char (match-end 0))
+ 			   (skip-syntax-forward " ")
+ 			   (looking-at change-log-tag-re))
+ 		  (change-log-search-tag-name-1)))
+ 	    (error nil))
+ 	  (condition-case nil
+ 	      ;; Before filename?
+ 	      (save-excursion
+ 		(when (and (progn
+ 			     (skip-syntax-backward " ")
+ 			     (beginning-of-line)
+ 			     (looking-at change-log-file-names-re))
+ 			   (goto-char (match-end 0))
+ 			   (skip-syntax-forward " ")
+ 			   (looking-at change-log-tag-re))
+ 		  (change-log-search-tag-name-1)))
+ 	    (error nil))
+ 	  (condition-case nil
+ 	      ;; Near start entry?
+ 	      (save-excursion
+ 		(when (and (progn
+ 			     (beginning-of-line)
+ 			     (looking-at change-log-start-entry-re))
+ 			   (forward-line) ; Won't work for multiple
+ 					  ; names, etc.
+ 			   (skip-syntax-forward " ")
+ 			   (progn
+ 			     (beginning-of-line)
+ 			     (looking-at change-log-file-names-re))
+ 			   (goto-char (match-end 0))
+ 			   (re-search-forward change-log-tag-re))
+ 		  (change-log-search-tag-name-1)))
+ 	    (error nil))
+ 	  (condition-case nil
+ 	      ;; After parenthesized list?.
+ 	      (when (re-search-backward change-log-tag-re)
+ 		(save-restriction
+ 		  (narrow-to-region (match-beginning 1) (match-end 1))
+ 		  (goto-char (point-max))
+ 		  (cons (find-tag-default) (point-max))))
+ 	    (error nil))))))
+ 
+ (defvar change-log-find-head nil)
+ (defvar change-log-find-tail nil)
+ 
+ (defun change-log-find-tag-1 (tag regexp file buffer
+ 				  &optional window first last)
+   "Search for tag TAG in buffer BUFFER visiting file FILE.
+ REGEXP is a regular expression for TAG.  The remaining arguments
+ are optional: WINDOW denotes the window to display the results of
+ the search.  FIRST is a position in BUFFER denoting the first
+ match from previous searches for TAG.  LAST is the position in
+ BUFFER denoting the last match for TAG in the last search."
+   (with-current-buffer buffer
+     (save-excursion
+       (save-restriction
+ 	(widen)
+ 	(if last
+ 	    (progn
+ 	      ;; When LAST is set make sure we continue from the next
+ 	      ;; line end to not find the same tag again.
+ 	      (goto-char last)
+ 	      (end-of-line)
+ 	      (condition-case nil
+ 		  ;; Try to go to the end of the current defun to avoid
+ 		  ;; false positives within the current defun's body
+ 		  ;; since these would match `add-log-current-defun'.
+ 		  (end-of-defun)
+ 		;; Don't fall behind when `end-of-defun' fails.
+ 		(error (progn (goto-char last) (end-of-line))))
+ 	      (setq last nil))
+ 	  ;; When LAST was not set start at beginning of BUFFER.
+ 	  (goto-char (point-min)))
+ 	(let (current-defun)
+ 	  (while (and (not last) (re-search-forward regexp nil t))
+ 	      ;; Verify that `add-log-current-defun' invoked at the end
+ 	      ;; of the match returns TAG.  This heuristic works well
+ 	      ;; whenever the name of the defun occurs within the first
+ 	      ;; line of the defun.
+ 	      (setq current-defun (add-log-current-defun))
+ 	      (when (and current-defun (string-equal current-defun tag))
+ 		;; Record this as last match.
+ 		(setq last (line-beginning-position))
+ 		;; Record this as first match when there's none.
+ 		(unless first (setq first last)))))))
+     (if (or last first)
+ 	(with-selected-window (or window (display-buffer buffer))
+ 	  (if last
+ 	      (progn
+ 		(when (or (< last (point-min)) (> last (point-max)))
+ 		  ;; Widen to show TAG.
+ 		  (widen))
+ 		(push-mark)
+ 		(goto-char last))
+ 	    ;; When there are no more matches go (back) to FIRST.
+ 	    (message "No more matches for `%s' in %s" tag file)
+ 	    (setq last first)
+ 	    (goto-char first))
+ 	  ;; Return new "tail".
+ 	  (list (selected-window) first last))
+       (message "Not found `%s' in %s" tag file)
+       nil)))
+ 
+ (defun change-log-find-tag ()
+   "Find source code for change log tag near `point'.
+ A tag is a symbol within a parenthesized, comma-separated list."
+   (interactive)
+   (if (and (eq last-command 'change-log-find-tag)
+ 	   change-log-find-tail)
+       (setq change-log-find-tail
+ 	    (condition-case nil
+ 		(apply 'change-log-find-tag-1
+ 		       (append change-log-find-head change-log-find-tail))
+ 	      (error
+ 	       (format "Cannot find more matches for `%s' in %s"
+ 		       (car change-log-find-head)
+ 		       (nth 2 change-log-find-head)))))
+     (save-excursion
+       (let* ((tag-at (change-log-search-tag-name))
+ 	     (tag (car tag-at))
+ 	     (file (when tag-at
+ 		     (change-log-search-file-name (cdr tag-at)))))
+ 	(if (not tag)
+ 	    (error "No suitable tag near `point'")
+ 	  (setq change-log-find-head
+ 		(list tag (concat "\\_<" (regexp-quote tag) "\\_>")
+ 		      file (find-file-noselect file)))
+ 	  (condition-case nil
+ 	      (setq change-log-find-tail
+ 		    (apply 'change-log-find-tag-1 change-log-find-head))
+ 	    (error (format "Cannot find matches for `%s' in %s"
+ 			   tag file))))))))
+ 
  (defvar change-log-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map [?\C-c ?\C-p] 'add-log-edit-prev-comment)
      (define-key map [?\C-c ?\C-n] 'add-log-edit-next-comment)
      (define-key map [?\C-c ?\C-f] 'change-log-find-file)
+     (define-key map [?\C-c ?\C-t] 'change-log-find-tag)
      map)
    "Keymap for Change Log major mode.")
  

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

* Re: Finding the source of Change Log entries
  2008-07-12  9:32 Finding the source of Change Log entries martin rudalics
@ 2008-07-12 10:00 ` Lennart Borgman (gmail)
  2008-07-12 10:32   ` martin rudalics
  2008-07-12 14:52 ` Chong Yidong
  2008-07-14 14:00 ` Dan Nicolaescu
  2 siblings, 1 reply; 30+ messages in thread
From: Lennart Borgman (gmail) @ 2008-07-12 10:00 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics wrote:
> Months ago I wrote a couple of functions to find the source code
> corresponding to Change Log entries.  Anyone still interested?

Sounds great though I have not tried it.




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

* Re: Finding the source of Change Log entries
  2008-07-12 10:00 ` Lennart Borgman (gmail)
@ 2008-07-12 10:32   ` martin rudalics
  0 siblings, 0 replies; 30+ messages in thread
From: martin rudalics @ 2008-07-12 10:32 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel

> Sounds great though I have not tried it.

Could you try it?

(Apply the patch, recompile, open a Change Log file, move to a change-log-list
entry, type C-c C-t, ... should take you two minutes at most ;-))






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

* Re: Finding the source of Change Log entries
  2008-07-12  9:32 Finding the source of Change Log entries martin rudalics
  2008-07-12 10:00 ` Lennart Borgman (gmail)
@ 2008-07-12 14:52 ` Chong Yidong
  2008-07-13  8:33   ` martin rudalics
  2008-07-14 13:50   ` Ted Zlatanov
  2008-07-14 14:00 ` Dan Nicolaescu
  2 siblings, 2 replies; 30+ messages in thread
From: Chong Yidong @ 2008-07-12 14:52 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

> Months ago I wrote a couple of functions to find the source code
> corresponding to Change Log entries.  Anyone still interested?

Looks good.  Please check it in, with the appropriate ChangeLog and NEWS
entries, plus the following fix:

+       (message "Not found `%s' in %s" tag file)

should be something more grammatical, like

+       (message "Source location not found: `%s' in %s" tag file)

Also, instead of binding change-log-find-tag to C-c C-t, how about using
C-c C-c for consistency with diff-mode?  (You might also want to rename
change-log-find-tag to change-log-goto-source for consistency with
diff-goto-source, but that's your call.)




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

* Re: Finding the source of Change Log entries
  2008-07-12 14:52 ` Chong Yidong
@ 2008-07-13  8:33   ` martin rudalics
  2008-07-13 22:14     ` Juri Linkov
  2008-07-14 13:50   ` Ted Zlatanov
  1 sibling, 1 reply; 30+ messages in thread
From: martin rudalics @ 2008-07-13  8:33 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> Please check it in, with the appropriate ChangeLog and NEWS
> entries, plus the following fix:
> 
> +       (message "Not found `%s' in %s" tag file)
> 
> should be something more grammatical, like
> 
> +       (message "Source location not found: `%s' in %s" tag file)
> 
> Also, instead of binding change-log-find-tag to C-c C-t, how about using
> C-c C-c for consistency with diff-mode?  (You might also want to rename
> change-log-find-tag to change-log-goto-source for consistency with
> diff-goto-source, but that's your call.)

Done.  Please check again.






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

* Re: Finding the source of Change Log entries
  2008-07-13  8:33   ` martin rudalics
@ 2008-07-13 22:14     ` Juri Linkov
  2008-07-14  8:40       ` martin rudalics
  0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2008-07-13 22:14 UTC (permalink / raw)
  To: martin rudalics; +Cc: Chong Yidong, emacs-devel

>> Please check it in, with the appropriate ChangeLog and NEWS
>> entries, plus the following fix:
>>
>> +       (message "Not found `%s' in %s" tag file)
>>
>> should be something more grammatical, like
>>
>> +       (message "Source location not found: `%s' in %s" tag file)
>>
>> Also, instead of binding change-log-find-tag to C-c C-t, how about using
>> C-c C-c for consistency with diff-mode?  (You might also want to rename
>> change-log-find-tag to change-log-goto-source for consistency with
>> diff-goto-source, but that's your call.)
>
> Done.  Please check again.

Thanks, this is great.  One thing that doesn't work yet is visiting
a file that has no tag, i.e.

	* filename.el: File-level changes.

Instead of visiting it, `C-c C-c' visits the previous file that has
a tag.  Of course, `C-c C-f' is available to visit a file, but it is
not convenient to switch between different keys to do the same thing,
and also `C-c C-f' has a different behavior: it visits a file in the
same window unlike `C-c C-c'.

It seems the best thing to do would be searching backward for a tag and
a file name at the same.  This may require joining two separate functions
that search a tag or a file name into one function.

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




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

* Re: Finding the source of Change Log entries
  2008-07-13 22:14     ` Juri Linkov
@ 2008-07-14  8:40       ` martin rudalics
  2008-07-14 21:57         ` Juri Linkov
  0 siblings, 1 reply; 30+ messages in thread
From: martin rudalics @ 2008-07-14  8:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Chong Yidong, emacs-devel

 > One thing that doesn't work yet is visiting
 > a file that has no tag, i.e.
 >
 > 	* filename.el: File-level changes.
 >
 > Instead of visiting it, `C-c C-c' visits the previous file that has
 > a tag.  Of course, `C-c C-f' is available to visit a file, but it is
 > not convenient to switch between different keys to do the same thing,
 > and also `C-c C-f' has a different behavior: it visits a file in the
 > same window unlike `C-c C-c'.
 >
 > It seems the best thing to do would be searching backward for a tag and
 > a file name at the same.  This may require joining two separate functions
 > that search a tag or a file name into one function.

If I understand my code correctly I first search for a tag (backward and
forward) and as soon as I found one I search for the first file name
preceding the tag.  Now if I find another file name in between the
position of the tag and `point' I could go to `point-min' in that file
instead.  Is it that what you mean?





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

* Re: Finding the source of Change Log entries
  2008-07-12 14:52 ` Chong Yidong
  2008-07-13  8:33   ` martin rudalics
@ 2008-07-14 13:50   ` Ted Zlatanov
  2008-07-14 21:54     ` Juri Linkov
  1 sibling, 1 reply; 30+ messages in thread
From: Ted Zlatanov @ 2008-07-14 13:50 UTC (permalink / raw)
  To: emacs-devel

On Sat, 12 Jul 2008 10:52:40 -0400 Chong Yidong <cyd@stupidchicken.com> wrote: 

CY> Also, instead of binding change-log-find-tag to C-c C-t, how about using
CY> C-c C-c for consistency with diff-mode?  (You might also want to rename
CY> change-log-find-tag to change-log-goto-source for consistency with
CY> diff-goto-source, but that's your call.)

Would it be acceptable to bind next-error and previous-error in this
mode, so users could use them to navigate between points of interest in
the ChangeLog, similar to error logs and grep/occur output?

I'd find that really helpful, and can write the glue code necessary.

Thanks
Ted





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

* Re: Finding the source of Change Log entries
  2008-07-12  9:32 Finding the source of Change Log entries martin rudalics
  2008-07-12 10:00 ` Lennart Borgman (gmail)
  2008-07-12 14:52 ` Chong Yidong
@ 2008-07-14 14:00 ` Dan Nicolaescu
  2008-07-16 17:18   ` martin rudalics
  2 siblings, 1 reply; 30+ messages in thread
From: Dan Nicolaescu @ 2008-07-14 14:00 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

  > Months ago I wrote a couple of functions to find the source code
  > corresponding to Change Log entries.  Anyone still interested?

This is nice!

May I suggest an extension?  
When using "C-x 4 a", maybe an overlay with a property pointing to the
source file/linenumber can be inserted over the ChangeLog text.  Then
C-c C-c could be more precise in finding the exact location from where
"C-x 4 a" was initially called.




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

* Re: Finding the source of Change Log entries
  2008-07-14 13:50   ` Ted Zlatanov
@ 2008-07-14 21:54     ` Juri Linkov
  2008-07-15  6:23       ` Andrew W. Nosenko
  0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2008-07-14 21:54 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

> CY> Also, instead of binding change-log-find-tag to C-c C-t, how about using
> CY> C-c C-c for consistency with diff-mode?  (You might also want to rename
> CY> change-log-find-tag to change-log-goto-source for consistency with
> CY> diff-goto-source, but that's your call.)
>
> Would it be acceptable to bind next-error and previous-error in this
> mode, so users could use them to navigate between points of interest in
> the ChangeLog, similar to error logs and grep/occur output?
>
> I'd find that really helpful, and can write the glue code necessary.

I think it would be a good thing, and this could be implemented
on top of Martin's code.

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




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

* Re: Finding the source of Change Log entries
  2008-07-14  8:40       ` martin rudalics
@ 2008-07-14 21:57         ` Juri Linkov
  2008-07-16 17:20           ` martin rudalics
  2008-08-07 10:10           ` martin rudalics
  0 siblings, 2 replies; 30+ messages in thread
From: Juri Linkov @ 2008-07-14 21:57 UTC (permalink / raw)
  To: martin rudalics; +Cc: Chong Yidong, emacs-devel

>> One thing that doesn't work yet is visiting
>> a file that has no tag, i.e.
>>
>> 	* filename.el: File-level changes.
>>
>> Instead of visiting it, `C-c C-c' visits the previous file that has
>> a tag.  Of course, `C-c C-f' is available to visit a file, but it is
>> not convenient to switch between different keys to do the same thing,
>> and also `C-c C-f' has a different behavior: it visits a file in the
>> same window unlike `C-c C-c'.
>>
>> It seems the best thing to do would be searching backward for a tag and
>> a file name at the same.  This may require joining two separate functions
>> that search a tag or a file name into one function.
>
> If I understand my code correctly I first search for a tag (backward and
> forward) and as soon as I found one I search for the first file name
> preceding the tag.  Now if I find another file name in between the
> position of the tag and `point' I could go to `point-min' in that file
> instead.  Is it that what you mean?

I mean rather the following case:

	* window.el (truncated-partial-width-window-p): New function.

	* menu-bar.el: Remove Longlines mode from menu.  Add word-wrap
	option.

When you type `C-c C-c' on the file name `menu-bar.el' (or anywhere
inside the text of its entry) it visits `truncated-partial-width-window-p'
in window.el instead of visiting the file menu-bar.el as it is more expected.

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




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

* Re: Finding the source of Change Log entries
  2008-07-14 21:54     ` Juri Linkov
@ 2008-07-15  6:23       ` Andrew W. Nosenko
  2008-07-15  9:48         ` Juri Linkov
  0 siblings, 1 reply; 30+ messages in thread
From: Andrew W. Nosenko @ 2008-07-15  6:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Ted Zlatanov, emacs-devel

On Tue, Jul 15, 2008 at 12:54 AM, Juri Linkov <juri@jurta.org> wrote:
>> CY> Also, instead of binding change-log-find-tag to C-c C-t, how about using
>> CY> C-c C-c for consistency with diff-mode?  (You might also want to rename
>> CY> change-log-find-tag to change-log-goto-source for consistency with
>> CY> diff-goto-source, but that's your call.)
>>
>> Would it be acceptable to bind next-error and previous-error in this
>> mode, so users could use them to navigate between points of interest in
>> the ChangeLog, similar to error logs and grep/occur output?
>>
>> I'd find that really helpful, and can write the glue code necessary.
>
> I think it would be a good thing, and this could be implemented
> on top of Martin's code.

Sorry, but I think that it would be the bad thing because could to
block regular C-x` usage just because my current (or last visited)
file was in ChangeLog mode...  Please, do not do this, or, if it
really needed for someone, keep it turned off by default.

-- 
Andrew W. Nosenko <andrew.w.nosenko@gmail.com>




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

* Re: Finding the source of Change Log entries
  2008-07-15  6:23       ` Andrew W. Nosenko
@ 2008-07-15  9:48         ` Juri Linkov
  2008-07-15 14:56           ` Ted Zlatanov
  0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2008-07-15  9:48 UTC (permalink / raw)
  To: Andrew W. Nosenko; +Cc: Ted Zlatanov, emacs-devel

>>> Would it be acceptable to bind next-error and previous-error in this
>>> mode, so users could use them to navigate between points of interest in
>>> the ChangeLog, similar to error logs and grep/occur output?
>>>
>>> I'd find that really helpful, and can write the glue code necessary.
>>
>> I think it would be a good thing, and this could be implemented
>> on top of Martin's code.
>
> Sorry, but I think that it would be the bad thing because could to
> block regular C-x` usage just because my current (or last visited)
> file was in ChangeLog mode...  Please, do not do this, or, if it
> really needed for someone, keep it turned off by default.

Don't worry, we already took care of this situation, so when a ChangeLog
file is visited by C-x `, the next C-x ` will not start visiting ChangeLog
entries.  Instead, it will continue visiting the initial list.  C-x ` will
visit ChangeLog entries only after you typed C-c C-c in the ChangeLog file
(thus initiated a new set of visiting points for C-x `).  For more information
you can read the thread http://thread.gmane.org/gmane.emacs.devel/22957

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




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

* Re: Finding the source of Change Log entries
  2008-07-15  9:48         ` Juri Linkov
@ 2008-07-15 14:56           ` Ted Zlatanov
  2008-07-15 20:35             ` Juri Linkov
  0 siblings, 1 reply; 30+ messages in thread
From: Ted Zlatanov @ 2008-07-15 14:56 UTC (permalink / raw)
  To: emacs-devel

On Tue, 15 Jul 2008 12:48:09 +0300 Juri Linkov <juri@jurta.org> wrote: 

>>>> Would it be acceptable to bind next-error and previous-error in this
>>>> mode, so users could use them to navigate between points of interest in
>>>> the ChangeLog, similar to error logs and grep/occur output?
>>>> 
>>>> I'd find that really helpful, and can write the glue code necessary.
>>> 
>>> I think it would be a good thing, and this could be implemented
>>> on top of Martin's code.
>> 
>> Sorry, but I think that it would be the bad thing because could to
>> block regular C-x` usage just because my current (or last visited)
>> file was in ChangeLog mode...  Please, do not do this, or, if it
>> really needed for someone, keep it turned off by default.

JL> Don't worry, we already took care of this situation, so when a ChangeLog
JL> file is visited by C-x `, the next C-x ` will not start visiting ChangeLog
JL> entries.  Instead, it will continue visiting the initial list.  C-x ` will
JL> visit ChangeLog entries only after you typed C-c C-c in the ChangeLog file
JL> (thus initiated a new set of visiting points for C-x `).  For more information
JL> you can read the thread http://thread.gmane.org/gmane.emacs.devel/22957

When change-log-find-tag is available in CVS (it's not checked in yet),
I'll write this glue code if there are no other objections.

Thanks
Ted





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

* Re: Finding the source of Change Log entries
  2008-07-15 14:56           ` Ted Zlatanov
@ 2008-07-15 20:35             ` Juri Linkov
  2008-07-16 17:20               ` martin rudalics
  2008-08-05 18:43               ` Ted Zlatanov
  0 siblings, 2 replies; 30+ messages in thread
From: Juri Linkov @ 2008-07-15 20:35 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

> When change-log-find-tag is available in CVS (it's not checked in yet),
> I'll write this glue code if there are no other objections.

IIUC, change-log-find-tag is already in CVS, but with a different name,
it was renamed to change-log-goto-source for consistency with
diff-goto-source.

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




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

* Re: Finding the source of Change Log entries
  2008-07-14 14:00 ` Dan Nicolaescu
@ 2008-07-16 17:18   ` martin rudalics
  2008-07-27 21:47     ` Dan Nicolaescu
  0 siblings, 1 reply; 30+ messages in thread
From: martin rudalics @ 2008-07-16 17:18 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

 > When using "C-x 4 a", maybe an overlay with a property pointing to the
 > source file/linenumber can be inserted over the ChangeLog text.  Then
 > C-c C-c could be more precise in finding the exact location from where
 > "C-x 4 a" was initially called.

I do not understand well why you want to do that.  If C-c C-c can't find
the position it's either a bug in `add-change-log-entry-other-window' or
in my code.  If the bug is with the latter I have to fix it.  If the bug
is with the former, you have to write your entry manually and creating
the overlay can hardly be done automatically.  Can you give me a more or
less practical scenario where such overlays would be useful?





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

* Re: Finding the source of Change Log entries
  2008-07-14 21:57         ` Juri Linkov
@ 2008-07-16 17:20           ` martin rudalics
  2008-08-07 10:10           ` martin rudalics
  1 sibling, 0 replies; 30+ messages in thread
From: martin rudalics @ 2008-07-16 17:20 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Chong Yidong, emacs-devel

 >>If I understand my code correctly I first search for a tag (backward and
 >>forward) and as soon as I found one I search for the first file name
 >>preceding the tag.  Now if I find another file name in between the
 >>position of the tag and `point' I could go to `point-min' in that file
 >>instead.  Is it that what you mean?
 >
 > I mean rather the following case:
 >
 > 	* window.el (truncated-partial-width-window-p): New function.
 >
 > 	* menu-bar.el: Remove Longlines mode from menu.  Add word-wrap
 > 	option.
 >
 > When you type `C-c C-c' on the file name `menu-bar.el' (or anywhere
 > inside the text of its entry) it visits `truncated-partial-width-window-p'
 > in window.el instead of visiting the file menu-bar.el as it is more expected.

So I suppose we mean the same thing.  I shall look into this in a couple of
days.





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

* Re: Finding the source of Change Log entries
  2008-07-15 20:35             ` Juri Linkov
@ 2008-07-16 17:20               ` martin rudalics
  2008-08-05 18:43               ` Ted Zlatanov
  1 sibling, 0 replies; 30+ messages in thread
From: martin rudalics @ 2008-07-16 17:20 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Ted Zlatanov, emacs-devel

> IIUC, change-log-find-tag is already in CVS, but with a different name,
> it was renamed to change-log-goto-source for consistency with
> diff-goto-source.

Indeed.





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

* Re: Finding the source of Change Log entries
  2008-07-16 17:18   ` martin rudalics
@ 2008-07-27 21:47     ` Dan Nicolaescu
  2008-07-28 18:50       ` martin rudalics
  0 siblings, 1 reply; 30+ messages in thread
From: Dan Nicolaescu @ 2008-07-27 21:47 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

  > > When using "C-x 4 a", maybe an overlay with a property pointing to the
  > > source file/linenumber can be inserted over the ChangeLog text.  Then
  > > C-c C-c could be more precise in finding the exact location from where
  > > "C-x 4 a" was initially called.
  > 
  > I do not understand well why you want to do that.  If C-c C-c can't find
  > the position it's either a bug in `add-change-log-entry-other-window' or
  > in my code.  If the bug is with the latter I have to fix it.  If the bug
  > is with the former, you have to write your entry manually and creating
  > the overlay can hardly be done automatically.  Can you give me a more or
  > less practical scenario where such overlays would be useful?

Sorry, for the late reply.
Sure, C-c C-c will find the beginning of a
function.  If the function is long, it would be better to go directly to
the point of the change.  Not sure that it would make enough of a
difference to make it worth it, but it might...




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

* Re: Finding the source of Change Log entries
  2008-07-27 21:47     ` Dan Nicolaescu
@ 2008-07-28 18:50       ` martin rudalics
  2008-07-28 21:53         ` Stefan Monnier
  0 siblings, 1 reply; 30+ messages in thread
From: martin rudalics @ 2008-07-28 18:50 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

 > If the function is long, it would be better to go directly to
 > the point of the change.  Not sure that it would make enough of a
 > difference to make it worth it, but it might...

Now I see what you mean.  The problem is that when I do C-x 4 a I'm
sometimes not at the position where I changed something but at some
arbitrary position within the function.  In that case the behavior you
suggest might be irritating.  But probably mine is just a bad habit.
Maybe we could make it customizable (the behavior, not my habit).

In any case, an overlay seems useful for the case where one adds
entries for a `defvar' and a `defun' with the same name.





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

* Re: Finding the source of Change Log entries
  2008-07-28 18:50       ` martin rudalics
@ 2008-07-28 21:53         ` Stefan Monnier
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Monnier @ 2008-07-28 21:53 UTC (permalink / raw)
  To: martin rudalics; +Cc: Dan Nicolaescu, emacs-devel

>> If the function is long, it would be better to go directly to
>> the point of the change.  Not sure that it would make enough of a
>> difference to make it worth it, but it might...

> Now I see what you mean.  The problem is that when I do C-x 4 a I'm
> sometimes not at the position where I changed something but at some
> arbitrary position within the function.  In that case the behavior you
> suggest might be irritating.  But probably mine is just a bad habit.
> Maybe we could make it customizable (the behavior, not my habit).

> In any case, an overlay seems useful for the case where one adds
> entries for a `defvar' and a `defun' with the same name.

I'm really not sure it's worth the trouble since it'll only work within
the same Emacs session (and only if you don't kill&reopen the ChangeLog
buffer, ...).


        Stefan




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

* Re: Finding the source of Change Log entries
  2008-07-15 20:35             ` Juri Linkov
  2008-07-16 17:20               ` martin rudalics
@ 2008-08-05 18:43               ` Ted Zlatanov
  2008-08-25 15:43                 ` Juri Linkov
  1 sibling, 1 reply; 30+ messages in thread
From: Ted Zlatanov @ 2008-08-05 18:43 UTC (permalink / raw)
  To: emacs-devel

On Tue, 15 Jul 2008 23:35:52 +0300 Juri Linkov <juri@jurta.org> wrote: 

>> When change-log-find-tag is available in CVS (it's not checked in yet),
>> I'll write this glue code if there are no other objections.

JL> IIUC, change-log-find-tag is already in CVS, but with a different name,
JL> it was renamed to change-log-goto-source for consistency with
JL> diff-goto-source.

change-log-mode now supports next-error.  Thanks for your help.

Ted





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

* Re: Finding the source of Change Log entries
  2008-07-14 21:57         ` Juri Linkov
  2008-07-16 17:20           ` martin rudalics
@ 2008-08-07 10:10           ` martin rudalics
  1 sibling, 0 replies; 30+ messages in thread
From: martin rudalics @ 2008-08-07 10:10 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Chong Yidong, emacs-devel

 > 	* window.el (truncated-partial-width-window-p): New function.
 >
 > 	* menu-bar.el: Remove Longlines mode from menu.  Add word-wrap
 > 	option.
 >
 > When you type `C-c C-c' on the file name `menu-bar.el' (or anywhere
 > inside the text of its entry) it visits `truncated-partial-width-window-p'
 > in window.el instead of visiting the file menu-bar.el as it is more expected.

I checked in a fix for this, please try.  This should also work with
`next-error' and `previous-error'.  Note, however, that these search for
`change-log-file-names-re', hence you get the first tag for each file
entry only.

martin





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

* Re: Finding the source of Change Log entries
  2008-08-05 18:43               ` Ted Zlatanov
@ 2008-08-25 15:43                 ` Juri Linkov
  2008-08-27 18:37                   ` Ted Zlatanov
  0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2008-08-25 15:43 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

>>> When change-log-find-tag is available in CVS (it's not checked in yet),
>>> I'll write this glue code if there are no other objections.
>
> JL> IIUC, change-log-find-tag is already in CVS, but with a different name,
> JL> it was renamed to change-log-goto-source for consistency with
> JL> diff-goto-source.
>
> change-log-mode now supports next-error.

Thanks.

I noticed one difference comparing with the standard behavior of
next-error.  In ChangeLog files it doesn't switch to the source
buffer: after calling `next-error', point stays in the ChangeLog buffer
instead of using pop-to-buffer to switch to the source buffer.

Also I think it is more useful to navigate by entries instead of file names,
(i.e. using change-log-start-entry-re instead of change-log-file-names-re).

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




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

* Re: Finding the source of Change Log entries
  2008-08-25 15:43                 ` Juri Linkov
@ 2008-08-27 18:37                   ` Ted Zlatanov
  2008-08-27 20:43                     ` Stefan Monnier
  2008-09-10 23:59                     ` Juri Linkov
  0 siblings, 2 replies; 30+ messages in thread
From: Ted Zlatanov @ 2008-08-27 18:37 UTC (permalink / raw)
  To: emacs-devel

On Mon, 25 Aug 2008 18:43:48 +0300 Juri Linkov <juri@jurta.org> wrote: 

>>>> When change-log-find-tag is available in CVS (it's not checked in yet),
>>>> I'll write this glue code if there are no other objections.
>> 
JL> IIUC, change-log-find-tag is already in CVS, but with a different name,
JL> it was renamed to change-log-goto-source for consistency with
JL> diff-goto-source.
>> 
>> change-log-mode now supports next-error.

JL> I noticed one difference comparing with the standard behavior of
JL> next-error.  In ChangeLog files it doesn't switch to the source
JL> buffer: after calling `next-error', point stays in the ChangeLog buffer
JL> instead of using pop-to-buffer to switch to the source buffer.

Unfortunately I think making that change would have broken
`change-log-goto-source', so I run an extra `find-file' after
`change-log-goto-source'.  Take a look and see if it works for you.  It
may be more appropriate with find-file-other-window to keep the
ChangeLog visible.

JL> Also I think it is more useful to navigate by entries instead of file names,
JL> (i.e. using change-log-start-entry-re instead of change-log-file-names-re).

I had that originally, but it's very common to have multi-file commits
and visiting each file proved (to me) to be useful.  Remember, this is
to visit the file referenced in the ChangeLog, not the ChangeLog entry
itself.

We can have the behavior customizable if you like to visit just entries.

Ted





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

* Re: Finding the source of Change Log entries
  2008-08-27 18:37                   ` Ted Zlatanov
@ 2008-08-27 20:43                     ` Stefan Monnier
  2008-08-27 20:57                       ` Ted Zlatanov
  2008-09-10 23:59                     ` Juri Linkov
  1 sibling, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2008-08-27 20:43 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

> `change-log-goto-source', so I run an extra `find-file' after

Never use `find-file' from Elisp, please.  Use pop-to-buffer (together
with find-file-noselect if necessary) instead,


        Stefan





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

* Re: Finding the source of Change Log entries
  2008-08-27 20:43                     ` Stefan Monnier
@ 2008-08-27 20:57                       ` Ted Zlatanov
  2008-08-28  2:03                         ` Stefan Monnier
  0 siblings, 1 reply; 30+ messages in thread
From: Ted Zlatanov @ 2008-08-27 20:57 UTC (permalink / raw)
  To: emacs-devel

On Wed, 27 Aug 2008 16:43:04 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote: 

>> `change-log-goto-source', so I run an extra `find-file' after
SM> Never use `find-file' from Elisp, please.  Use pop-to-buffer (together
SM> with find-file-noselect if necessary) instead,

Hmm, why does `change-log-find-file' use it?  Is it OK because it's a
wrapper around it?  That's where I saw the usage, sorry about it.

I've changed it to use `pop-to-buffer' but now it doesn't keep the
original ChangeLog window visible after the first time you run
`next-error'.  IOW, you see the ChangeLog the first time you run the
command, but after that it gets buried under the newly found file.

Sorry if this is not helpful, I haven't worked much with window
configurations and arrangements in ELisp.  If someone more knowledgeable
wants to take a look, please do.

Ted





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

* Re: Finding the source of Change Log entries
  2008-08-27 20:57                       ` Ted Zlatanov
@ 2008-08-28  2:03                         ` Stefan Monnier
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Monnier @ 2008-08-28  2:03 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

>>> `change-log-goto-source', so I run an extra `find-file' after
SM> Never use `find-file' from Elisp, please.  Use pop-to-buffer (together
SM> with find-file-noselect if necessary) instead,

> Hmm, why does `change-log-find-file' use it?  Is it OK because it's a
> wrapper around it?  That's where I saw the usage, sorry about it.

> I've changed it to use `pop-to-buffer' but now it doesn't keep the
> original ChangeLog window visible after the first time you run
> `next-error'.  IOW, you see the ChangeLog the first time you run the
> command, but after that it gets buried under the newly found file.

> Sorry if this is not helpful, I haven't worked much with window
> configurations and arrangements in ELisp.  If someone more knowledgeable
> wants to take a look, please do.

Try to make sure your code behaves like compilation-next-error-function.
E.g. it may want to use display-buffer rather than pop-to-buffer.
Once you've figured out the trick that makes it work right, please
improve the docstring of next-error-function so it explains clearly
where/if the buffer should be displayed.


        Stefan




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

* Re: Finding the source of Change Log entries
  2008-08-27 18:37                   ` Ted Zlatanov
  2008-08-27 20:43                     ` Stefan Monnier
@ 2008-09-10 23:59                     ` Juri Linkov
  2008-09-14 11:27                       ` martin rudalics
  1 sibling, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2008-09-10 23:59 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

> JL> I noticed one difference comparing with the standard behavior of
> JL> next-error.  In ChangeLog files it doesn't switch to the source
> JL> buffer: after calling `next-error', point stays in the ChangeLog buffer
> JL> instead of using pop-to-buffer to switch to the source buffer.
>
> Unfortunately I think making that change would have broken
> `change-log-goto-source', so I run an extra `find-file' after
> `change-log-goto-source'.  Take a look and see if it works for you.  It
> may be more appropriate with find-file-other-window to keep the
> ChangeLog visible.

Still doesn't work.  Replacing `pop-to-buffer' with `display-buffer'
at least doesn't hide the ChangeLog buffer, but point is in the wrong
buffer: unlike occur/grep modes, point stays in the ChangeLog buffer
instead of switching to the source buffer.

> JL> Also I think it is more useful to navigate by entries instead of file names,
> JL> (i.e. using change-log-start-entry-re instead of change-log-file-names-re).
>
> I had that originally, but it's very common to have multi-file commits
> and visiting each file proved (to me) to be useful.  Remember, this is
> to visit the file referenced in the ChangeLog, not the ChangeLog entry
> itself.

I remember we already agreed to add a pair of new next-file functions
to jump the next/previous file like compilation-next-file and
compilation-previous-file.  Such commands would be useful for
all next-error aware modes like occur, grep, ChangeLog, etc.

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




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

* Re: Finding the source of Change Log entries
  2008-09-10 23:59                     ` Juri Linkov
@ 2008-09-14 11:27                       ` martin rudalics
  0 siblings, 0 replies; 30+ messages in thread
From: martin rudalics @ 2008-09-14 11:27 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Ted Zlatanov, emacs-devel

 > Still doesn't work.  Replacing `pop-to-buffer' with `display-buffer'
 > at least doesn't hide the ChangeLog buffer, but point is in the wrong
 > buffer: unlike occur/grep modes, point stays in the ChangeLog buffer
 > instead of switching to the source buffer.

I checked in a fix, please try.

martin




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

end of thread, other threads:[~2008-09-14 11:27 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-12  9:32 Finding the source of Change Log entries martin rudalics
2008-07-12 10:00 ` Lennart Borgman (gmail)
2008-07-12 10:32   ` martin rudalics
2008-07-12 14:52 ` Chong Yidong
2008-07-13  8:33   ` martin rudalics
2008-07-13 22:14     ` Juri Linkov
2008-07-14  8:40       ` martin rudalics
2008-07-14 21:57         ` Juri Linkov
2008-07-16 17:20           ` martin rudalics
2008-08-07 10:10           ` martin rudalics
2008-07-14 13:50   ` Ted Zlatanov
2008-07-14 21:54     ` Juri Linkov
2008-07-15  6:23       ` Andrew W. Nosenko
2008-07-15  9:48         ` Juri Linkov
2008-07-15 14:56           ` Ted Zlatanov
2008-07-15 20:35             ` Juri Linkov
2008-07-16 17:20               ` martin rudalics
2008-08-05 18:43               ` Ted Zlatanov
2008-08-25 15:43                 ` Juri Linkov
2008-08-27 18:37                   ` Ted Zlatanov
2008-08-27 20:43                     ` Stefan Monnier
2008-08-27 20:57                       ` Ted Zlatanov
2008-08-28  2:03                         ` Stefan Monnier
2008-09-10 23:59                     ` Juri Linkov
2008-09-14 11:27                       ` martin rudalics
2008-07-14 14:00 ` Dan Nicolaescu
2008-07-16 17:18   ` martin rudalics
2008-07-27 21:47     ` Dan Nicolaescu
2008-07-28 18:50       ` martin rudalics
2008-07-28 21:53         ` Stefan Monnier

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