-
Notifications
You must be signed in to change notification settings - Fork 2
/
pjb-find-tag-hook.el
95 lines (87 loc) · 3.81 KB
/
pjb-find-tag-hook.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;;; -*- mode:emacs-lisp;coding:utf-8 -*-
;;;;**************************************************************************
;;;;FILE: pjb-find-tag-hook.el
;;;;LANGUAGE: emacs lisp
;;;;SYSTEM: POSIX
;;;;USER-INTERFACE: NONE
;;;;DESCRIPTION
;;;;
;;;; find-tag hook
;;;;
;;;;AUTHORS
;;;; <PJB> Pascal J. Bourguignon <[email protected]>
;;;;MODIFICATIONS
;;;; 2015-08-20 <PJB> Extracted from ~/rc/emacs-common.el
;;;;BUGS
;;;;LEGAL
;;;; AGPL3
;;;;
;;;; Copyright Pascal J. Bourguignon 2015 - 2015
;;;;
;;;; This program is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU Affero General Public License as published by
;;;; the Free Software Foundation, either version 3 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU Affero General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Affero General Public License
;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;**************************************************************************
(require 'pjb-cl)
(defstruct location buffer file-name line-number line-contents)
(defun %find-tag-locations-in-order ()
(message "%%find-tag-locations-in-order enters tagname=%S next-p=%S regexp-p=%S"
tagname next-p regexp-p)
(loop
with locations = '()
for (buffer err) = (cl:ignore-errors (find-tag-noselect tagname nil regexp-p))
then (cl:ignore-errors (find-tag-noselect tagname t regexp-p))
initially (message "%%find-tag-locations-in-order initially")
do (message "buffer = %S" buffer)
while buffer
collect (with-current-buffer buffer
(make-location
:buffer (current-buffer)
:file-name (buffer-file-name (current-buffer))
:line-number (count-lines (point-min) (point-at-bol))
:line-contents (buffer-substring-no-properties
(point-at-bol) (point-at-eol))))
finally (message "%%find-tag-locations-in-order exists %S" locations) (return (values locations err))))
(defun pjb-find-tag-meat ()
(message "pjb-find-tag-meat enters")
(unless next-p
(message "pjb-find-tag-meat 1")
(handler-case
(multiple-value-bind (locations error) (%find-tag-locations-in-order)
(message " locations (2) = %S" locations)
(if locations
(progn
(message "pjb-find-tag-meat 2")
(save-excursion
(message "pjb-find-tag-meat 3")
(switch-to-buffer-other-window (get-buffer-create
(format "*tags on %s*" tagname)))
(erase-buffer)
(compilation-mode 1)
(message "pjb-find-tag-meat 4")
(dolist (loc locations)
(insert (format "%s:%s %s\n"
(location-file-name loc)
(location-line-number loc)
(location-line-contents loc))))
(message "pjb-find-tag-meat 5"))
(message "pjb-find-tag-meat 6")
(message "pjb-find-tag-meat exits %S" (location-buffer (first locations)))
(location-buffer (first locations)))
(when error
(signal (car error) (cdr error)))))
(error (err)
(message "pjb-find-tag-meat 7")
(message "%s" err)))))
;; (add-hook 'find-tag-hook (function pjb-find-tag-meat))
;; (setq find-tag-hook nil)
;;;; THE END;;;;