From: martin rudalics <rudalics@gmx.at>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: juri@jurta.org, rgm@gnu.org, emacs-devel@gnu.org, rms@gnu.org,
janneke-list@xs4all.nl
Subject: Re: patch: add-log.el: changelog find file under poin
Date: Mon, 28 Jan 2008 11:20:05 +0100 [thread overview]
Message-ID: <479DAC55.8070302@gmx.at> (raw)
In-Reply-To: <200801271954.m0RJsmBm003714@sallyv1.ics.uci.edu>
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
> Based on that I checked this original patch in (Thanks Jan!).
> And I made it a bit more robust in finding the correct file name.
> If someone can figure out a way to use ffap that is at least as
> reliable, then we can replace the current code.
Based on what you wrote and Imenu I added support to find the "tag"
within the file with C-c C-t. Rudimentary and largely untested!
If anyone is interested I can refine that though.
[-- Attachment #2: add-log.patch --]
[-- Type: text/plain, Size: 4947 bytes --]
*** add-log.el Sun Jan 27 22:30:56 2008
--- add-log.el Mon Jan 28 11:16:12 2008
***************
*** 328,338 ****
--- 328,456 ----
(find-file file)
(message "No such file or directory: %s" file))))
+ (defconst change-log-tag-re "(\\(\\(?:\\sw\\|\\s_\\)+\\(?:,[ \t]+\\(?:\\sw\\|\\s_\\)+\\)*\\))")
+
+ (defun change-log-search-tag (&optional at)
+ "Search for something qualifying as tag."
+ (save-excursion
+ (goto-char (setq at (or at (point))))
+ (save-restriction
+ (widen)
+ (or (condition-case nil
+ ;; Test for AT within list containing tags.
+ (save-excursion
+ (backward-up-list)
+ (when (looking-at change-log-tag-re)
+ (goto-char at)
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (find-tag-default))))
+ (error nil))
+ (condition-case nil
+ ;; Test for AT before list containing tags.
+ (save-excursion
+ (when (and (skip-chars-forward " \t") ; syntax goes to far
+ (looking-at change-log-tag-re))
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (goto-char (point-min))
+ (find-tag-default))))
+ (error nil))
+ (condition-case nil
+ ;; Test for AT 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))
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (goto-char (point-min))
+ (find-tag-default))))
+ (error nil))
+ (condition-case nil
+ ;; Test for AT 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))
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (goto-char (point-min))
+ (find-tag-default))))
+ (error nil))
+ (condition-case nil
+ ;; Test for AT 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))
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (goto-char (point-min))
+ (find-tag-default))))
+ (error nil))
+ (condition-case nil
+ ;; Test for AT after tag list.
+ (when (re-search-backward change-log-tag-re)
+ (save-restriction
+ (narrow-to-region (match-beginning 1) (match-end 1))
+ (goto-char (point-max))
+ (find-tag-default)))
+ (error nil))))))
+
+ (defun change-log-find-tag ()
+ "Find tag using Imenu."
+ (interactive)
+ (let ((file (change-log-search-file-name (point)))
+ (tag (change-log-search-tag (point))))
+ (cond
+ ((and tag file (file-exists-p file))
+ (let ((buffer (find-file-noselect file))
+ position)
+ (if buffer
+ (with-current-buffer buffer
+ (require 'imenu)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (condition-case nil
+ (let* (imenu-use-markers element ; don't use markers.
+ (tags (funcall imenu-create-index-function)))
+ ;; TODO: Handle case of more than one
+ ;; association for tag.
+ (if (setq element (assoc tag tags))
+ (setq position (cdr element))
+ (message "Not found tag: %s" tag)))
+ (error nil))))
+ (when position
+ (goto-char position)
+ (display-buffer buffer)))
+ (message "Cannot find file: %s" file))))
+ ((not tag) (message "No such tag: %s" tag))
+ (t (message "No such file or directory: %s" 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.")
***************
*** 938,944 ****
having-next-defun
previous-defun-end
next-defun-beginning)
!
(save-excursion
(setq having-previous-defun
(c-beginning-of-defun))
--- 1056,1062 ----
having-next-defun
previous-defun-end
next-defun-beginning)
!
(save-excursion
(setq having-previous-defun
(c-beginning-of-defun))
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2008-01-28 10:20 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-04 21:18 patch: add-log.el: changelog find file under poin Jan Nieuwenhuizen
2007-11-06 23:45 ` Juri Linkov
2007-11-07 13:38 ` Jan Nieuwenhuizen
2007-11-09 8:40 ` Dan Nicolaescu
2007-11-09 9:40 ` Juri Linkov
2008-01-20 6:14 ` Richard Stallman
2008-01-21 3:02 ` Glenn Morris
2008-01-21 20:30 ` Richard Stallman
2008-01-21 20:35 ` Glenn Morris
2008-01-22 22:29 ` Richard Stallman
2008-01-22 22:38 ` Glenn Morris
2008-01-22 23:09 ` Dan Nicolaescu
2008-01-23 1:32 ` Juri Linkov
2008-01-23 2:25 ` Dan Nicolaescu
2008-01-23 9:28 ` Juri Linkov
2008-01-23 16:20 ` Richard Stallman
2008-01-27 19:54 ` Dan Nicolaescu
2008-01-28 10:20 ` martin rudalics [this message]
2008-01-30 2:58 ` Dan Nicolaescu
2008-02-18 19:46 ` patch: add-log.el: changelog find file under point martin rudalics
2008-02-18 20:09 ` Unbearably slow editing in .h files (was: patch: add-log.el: changelog find file under point) Stefan Monnier
2008-02-23 22:49 ` Alan Mackenzie
2008-02-23 22:51 ` Unbearably slow editing in .h files martin rudalics
2008-02-23 23:25 ` Alan Mackenzie
2008-02-24 8:55 ` martin rudalics
2008-04-02 22:07 ` Alan Mackenzie
2008-04-02 23:47 ` Dan Nicolaescu
2008-04-03 9:14 ` Alan Mackenzie
2008-04-03 13:10 ` Dan Nicolaescu
2008-04-03 14:17 ` Alan Mackenzie
2008-04-03 15:22 ` Dan Nicolaescu
2008-04-03 17:58 ` Alan Mackenzie
2008-02-24 0:37 ` Stefan Monnier
2008-02-24 8:39 ` Alan Mackenzie
2008-02-24 14:46 ` Jason Rumney
2008-02-24 19:48 ` Eli Zaretskii
2008-02-24 19:49 ` Eli Zaretskii
2008-02-24 10:28 ` Andreas Schwab
2008-02-24 13:49 ` Stefan Monnier
2008-02-24 14:41 ` Alan Mackenzie
2008-02-24 15:42 ` Stefan Monnier
2008-02-24 20:12 ` Alan Mackenzie
2008-02-24 22:29 ` Richard Stallman
2008-02-25 2:14 ` Stefan Monnier
2008-02-18 23:31 ` patch: add-log.el: changelog find file under point Juri Linkov
2008-02-19 6:34 ` martin rudalics
2008-02-20 21:29 ` Juri Linkov
2008-02-21 7:26 ` martin rudalics
2008-02-21 22:29 ` Richard Stallman
2008-02-22 19:26 ` martin rudalics
2008-02-23 19:28 ` Richard Stallman
2008-02-23 22:32 ` martin rudalics
2008-02-24 15:23 ` Richard Stallman
2008-02-24 15:23 ` Richard Stallman
2008-02-24 22:34 ` martin rudalics
2008-02-25 10:57 ` Richard Stallman
2008-02-25 14:05 ` martin rudalics
2008-01-22 0:08 ` patch: add-log.el: changelog find file under poin Juri Linkov
2008-01-22 1:17 ` Drew Adams
2008-01-22 9:54 ` Juri Linkov
2008-01-22 14:34 ` Drew Adams
2008-01-22 22:29 ` Richard Stallman
2008-01-23 1:29 ` Juri Linkov
2008-01-23 16:20 ` Richard Stallman
2008-01-28 8:55 ` Jan Nieuwenhuizen
2008-01-28 9:29 ` Johan Bockgård
2008-01-22 8:21 ` Dan Nicolaescu
2008-01-22 9:56 ` Juri Linkov
2008-01-22 23:13 ` Dan Nicolaescu
2008-01-22 22:29 ` Richard Stallman
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=479DAC55.8070302@gmx.at \
--to=rudalics@gmx.at \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
--cc=janneke-list@xs4all.nl \
--cc=juri@jurta.org \
--cc=rgm@gnu.org \
--cc=rms@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.