0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hibtypes.el
|
|
4 ;; SUMMARY: Hyperbole System Implicit Button Types.
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: extensions, hypermedia
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
100
|
9 ;; ORG: InfoDock Associates
|
|
10 ;;
|
|
11 ;; This file is part of Hyperbole.
|
|
12 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
13 ;;
|
|
14 ;; Copyright (C) 1991-1997 Free Software Foundation, Inc.
|
|
15 ;; Developed with support from Motorola Inc.
|
0
|
16 ;;
|
|
17 ;; ORIG-DATE: 19-Sep-91 at 20:45:31
|
100
|
18 ;; LAST-MOD: 20-Feb-97 at 11:17:04 by Bob Weiner
|
|
19
|
0
|
20 ;;; ************************************************************************
|
|
21 ;;; Other required Elisp libraries
|
|
22 ;;; ************************************************************************
|
|
23
|
|
24 (require 'hactypes)
|
|
25
|
|
26 ;;; ************************************************************************
|
|
27 ;;; Public implicit button types
|
|
28 ;;; ************************************************************************
|
|
29
|
|
30 (run-hooks 'hibtypes:begin-load-hook)
|
|
31
|
|
32 ;;; ========================================================================
|
100
|
33 ;;; Use func-menu.el to jump to a function referred to in the same file in
|
|
34 ;;; which it is defined. Function references across files are handled
|
|
35 ;;; separately be clauses within the `hkey-alist' variable.
|
|
36 ;;; ========================================================================
|
|
37
|
|
38 (defib function-in-buffer ()
|
|
39 "Return function name defined within this buffer that point is within or after, else nil.
|
|
40 This triggers only when the func-menu.el package has been loaded and the
|
|
41 current major mode is one handled by func-menu."
|
|
42 (if (and (boundp 'fume-function-name-regexp-alist)
|
|
43 (assq major-mode fume-function-name-regexp-alist)
|
|
44 (not (eq major-mode 'dired-mode))
|
|
45 ;; Not sure if this is defined in early versions of Emacs.
|
|
46 (fboundp 'skip-syntax-backward))
|
|
47 (save-excursion
|
|
48 (skip-syntax-backward "w_")
|
|
49 (if (looking-at "\\(\\sw\\|\\s_\\)+")
|
|
50 (let ((function-name (buffer-substring (point) (match-end 0)))
|
|
51 (start (point))
|
|
52 (end (match-end 0))
|
|
53 function-pos)
|
|
54 (if fume-funclist
|
|
55 nil
|
|
56 (fume-set-defaults)
|
|
57 (let ((fume-scanning-message nil))
|
|
58 (fume-rescan-buffer)))
|
|
59 (setq function-pos (cdr-safe (assoc function-name fume-funclist)))
|
|
60 (if function-pos
|
|
61 (progn (ibut:label-set function-name start end)
|
|
62 (hact 'function-in-buffer function-name
|
|
63 function-pos))))))))
|
|
64
|
|
65 ;;; ========================================================================
|
0
|
66 ;;; Follows URLs by invoking a browser.
|
|
67 ;;; ========================================================================
|
|
68
|
|
69 (require 'hsys-w3)
|
|
70
|
|
71 ;;; ========================================================================
|
|
72 ;;; Handles internal references within an annotated bibliography, delimiters=[]
|
|
73 ;;; ========================================================================
|
|
74
|
|
75 (defib annot-bib ()
|
|
76 "Displays annotated bibliography entries referenced internally.
|
|
77 References must be delimited by square brackets, must begin with a word
|
|
78 constituent character, and must not be in buffers whose names begin with a
|
|
79 ' ' or '*' character or which do not have an attached file."
|
|
80 (and (not (bolp))
|
|
81 buffer-file-name
|
|
82 (let ((chr (aref (buffer-name) 0)))
|
|
83 (not (or (= chr ? ) (= chr ?*))))
|
100
|
84 ;; Force [PPG-sw-process-id], if defined, to take precedence.
|
|
85 (not (htype:names 'ibtypes 'ppg-sw-process))
|
0
|
86 (let* ((ref-and-pos (hbut:label-p t "[" "]" t))
|
|
87 (ref (car ref-and-pos)))
|
|
88 (and ref (= ?w (char-syntax (aref ref 0)))
|
|
89 (progn (ibut:label-set ref-and-pos)
|
|
90 (hact 'annot-bib ref))))))
|
|
91
|
|
92 ;;; ========================================================================
|
|
93 ;;; Summarizes an Internet rfc for random access browsing by section.
|
|
94 ;;; ========================================================================
|
|
95
|
|
96 (defib rfc-toc ()
|
|
97 "Summarizes contents of an Internet rfc from anywhere within rfc buffer.
|
|
98 Each line in summary may be selected to jump to section."
|
|
99 (let ((case-fold-search t)
|
|
100 (toc)
|
|
101 (opoint (point)))
|
|
102 (if (and (string-match "rfc" (buffer-name))
|
|
103 (goto-char (point-min))
|
|
104 (progn (setq toc (search-forward "Table of Contents" nil t))
|
|
105 (re-search-forward "^[ \t]*1.0?[ \t]+[^ \t\n]" nil t
|
|
106 (and toc 2))))
|
|
107 (progn (beginning-of-line)
|
|
108 (ibut:label-set (buffer-name))
|
|
109 (hact 'rfc-toc (buffer-name) opoint))
|
|
110 (goto-char opoint)
|
|
111 nil)))
|
|
112
|
|
113 ;;; ========================================================================
|
|
114 ;;; Jumps to C/C++ source line associated with Cscope C analyzer output line.
|
|
115 ;;; ========================================================================
|
|
116
|
|
117 (defib cscope ()
|
|
118 "Jumps to C/C++ source line associated with Cscope C analyzer output line.
|
|
119 Requires pre-loading of the cscope.el Lisp library available from the Emacs
|
|
120 Lisp archives and the commercial cscope program available from UNIX System
|
|
121 Laboratories. Otherwise, does nothing."
|
|
122 (and (boundp 'cscope:bname-prefix) ;; (featurep 'cscope)
|
|
123 (stringp cscope:bname-prefix)
|
|
124 (string-match (regexp-quote cscope:bname-prefix)
|
|
125 (buffer-name))
|
|
126 (= (match-beginning 0) 0)
|
|
127 (save-excursion
|
|
128 (beginning-of-line)
|
|
129 (looking-at cscope-output-line-regexp))
|
|
130 (let (start end)
|
|
131 (skip-chars-backward "^\n\^M")
|
|
132 (setq start (point))
|
|
133 (skip-chars-forward "^\n\^M")
|
|
134 (setq end (point))
|
|
135 (ibut:label-set (buffer-substring start end)
|
|
136 start end)
|
|
137 (hact 'cscope-interpret-output-line))))
|
|
138
|
|
139 ;;; ========================================================================
|
|
140 ;;; Makes README table of contents entries jump to associated sections.
|
|
141 ;;; ========================================================================
|
|
142
|
|
143 (defib text-toc ()
|
|
144 "Jumps to the text file section referenced by a table of contents entry at point.
|
|
145 File name must contain README and there must be a `Table of Contents' or
|
|
146 `Contents' label on a line by itself (it may begin with an asterisk),
|
|
147 preceding the table of contents. Each toc entry must begin with some
|
|
148 whitespace followed by one or more asterisk characters. Each file section
|
|
149 name line must start with one or more asterisk characters at the very
|
|
150 beginning of the line."
|
|
151 (let (section)
|
|
152 (if (and (string-match "README" (buffer-name))
|
|
153 (save-excursion
|
|
154 (beginning-of-line)
|
|
155 (if (looking-at
|
|
156 "[ \t]+\\*+[ \t]+\\(.*[^ \t]\\)[ \t]*$")
|
|
157 (setq section (buffer-substring (match-beginning 1)
|
|
158 (match-end 1)))))
|
|
159 (progn (ibut:label-set section (match-beginning 1) (match-end 1))
|
|
160 t)
|
|
161 (save-excursion (re-search-backward
|
|
162 "^\\**[ \t]*\\(Table of \\)Contents[ \t]*$"
|
|
163 nil t)))
|
|
164 (hact 'text-toc section))))
|
|
165
|
|
166 ;;; ========================================================================
|
|
167 ;;; Makes directory summaries into file list menus.
|
|
168 ;;; ========================================================================
|
|
169
|
|
170 (defib dir-summary ()
|
|
171 "Detects filename buttons in files named \"MANIFEST\" or \"DIR\".
|
|
172 Displays selected files. Each file name must be at the beginning of the line
|
|
173 or may be preceded by some semicolons and must be followed by one or more
|
|
174 spaces and then another non-space, non-parenthesis, non-brace character."
|
|
175 (if buffer-file-name
|
|
176 (let ((file (file-name-nondirectory buffer-file-name))
|
|
177 entry start end)
|
|
178 (if (or (string= file "DIR") (string= file "MANIFEST"))
|
|
179 (save-excursion
|
|
180 (beginning-of-line)
|
|
181 (if (looking-at
|
|
182 "\\(;+[ \t]*\\)?\\([^(){}* \t\n]+\\)[ \t]+[^(){}* \t\n]")
|
|
183 (progn
|
|
184 (setq entry (buffer-substring
|
|
185 (match-beginning 2) (match-end 2))
|
|
186 start (match-beginning 2)
|
|
187 end (match-end 2))
|
|
188 (if (file-exists-p entry)
|
|
189 (progn (ibut:label-set entry start end)
|
|
190 (hact 'link-to-file entry))))))))))
|
|
191
|
|
192 ;;; ========================================================================
|
|
193 ;;; Executes or documents command bindings of brace delimited key sequences.
|
|
194 ;;; ========================================================================
|
|
195
|
|
196 (require 'hib-kbd)
|
|
197
|
|
198 ;;; ========================================================================
|
|
199 ;;; Makes Internet RFC references retrieve the RFC.
|
|
200 ;;; ========================================================================
|
|
201
|
|
202 (defib rfc ()
|
|
203 "Retrieves and displays an Internet rfc referenced at point.
|
|
204 Requires ange-ftp or efs when needed for remote retrievals. The following
|
|
205 formats are recognized: RFC822, rfc-822, and RFC 822. The 'hpath:rfc'
|
|
206 variable specifies the location from which to retrieve RFCs."
|
|
207 (let ((case-fold-search t)
|
|
208 (rfc-num nil))
|
|
209 (and (not (memq major-mode '(dired-mode monkey-mode)))
|
|
210 (boundp 'hpath:rfc)
|
|
211 (stringp hpath:rfc)
|
|
212 (save-excursion
|
|
213 (skip-chars-backward "-rRfFcC0-9")
|
|
214 (if (looking-at "rfc[- ]?\\([0-9]+\\)")
|
|
215 (progn
|
|
216 (setq rfc-num
|
|
217 (buffer-substring
|
|
218 (match-beginning 1) (match-end 1)))
|
|
219 (ibut:label-set
|
|
220 (buffer-substring (match-beginning 0) (match-end 0)))
|
|
221 t)))
|
|
222 ;; Ensure ange-ftp is available for retrieving a remote
|
|
223 ;; RFC, if need be.
|
|
224 (if (string-match "^/.+:" hpath:rfc)
|
|
225 ;; This is a remote path.
|
|
226 (hpath:ange-ftp-available-p)
|
|
227 ;; local path
|
|
228 t)
|
|
229 (hact 'link-to-rfc rfc-num))))
|
|
230
|
|
231 ;;; ========================================================================
|
|
232 ;;; Makes Hyperbole mail addresses output Hyperbole envir info.
|
|
233 ;;; ========================================================================
|
|
234
|
|
235 (defib hyp-address ()
|
|
236 "Turns a Hyperbole e-mail list address into an implicit button which inserts Hyperbole environment information.
|
|
237 Useful when sending mail to a Hyperbole mail list.
|
|
238 See also the documentation for `actypes::hyp-config'."
|
|
239 (if (memq major-mode (list hmail:composer hnews:composer))
|
|
240 (let ((addr (find-tag-default)))
|
100
|
241 (cond ((set:member addr (list "hyperbole" "hyperbole@infodock.com"))
|
0
|
242 (hact 'hyp-config))
|
|
243 ((set:member addr
|
|
244 (list "hyperbole-request"
|
100
|
245 "hyperbole-request@infodock.com"))
|
0
|
246 (hact 'hyp-request))
|
|
247 ))))
|
|
248
|
|
249 ;;; ========================================================================
|
|
250 ;;; Makes source entries in Hyperbole reports selectable.
|
|
251 ;;; ========================================================================
|
|
252
|
|
253 (defib hyp-source ()
|
|
254 "Turns source location entries in Hyperbole reports into buttons that jump to the associated location."
|
|
255 (save-excursion
|
|
256 (beginning-of-line)
|
|
257 (if (looking-at hbut:source-prefix)
|
|
258 (let ((src (hbut:source)))
|
|
259 (if src
|
|
260 (progn (if (not (stringp src)) (setq src (prin1-to-string src)))
|
|
261 (ibut:label-set src (point) (progn (end-of-line) (point)))
|
|
262 (hact 'hyp-source src)))))))
|
|
263
|
|
264 ;;; ========================================================================
|
|
265 ;;; Shows man page associated with a man apropos entry.
|
|
266 ;;; ========================================================================
|
|
267
|
|
268 (defib man-apropos ()
|
|
269 "Makes man apropos entries display associated man pages when selected."
|
|
270 (save-excursion
|
|
271 (beginning-of-line)
|
|
272 (let ((nm "[^ \t\n!@,][^ \t\n,]*")
|
|
273 topic)
|
|
274 (and (looking-at
|
|
275 (concat
|
|
276 "^\\(\\*[ \t]+[!@]\\)?\\(" nm "[ \t]*,[ \t]*\\)*\\(" nm "\\)[ \t]*"
|
|
277 "\\(([-0-9a-zA-z]+)\\)\\(::\\)?[ \t]+-[ \t]+[^ \t\n]"))
|
|
278 (setq topic
|
|
279 (concat (buffer-substring (match-beginning 3) (match-end 3))
|
|
280 (buffer-substring (match-beginning 4) (match-end 4))))
|
|
281 (ibut:label-set topic (match-beginning 3) (match-end 4))
|
|
282 (hact 'man-show topic)))))
|
|
283
|
|
284 ;;; ========================================================================
|
|
285 ;;; Follows links to Hyperbole outliner cells.
|
|
286 ;;; ========================================================================
|
|
287
|
|
288 (if hyperb:kotl-p (require 'klink))
|
|
289
|
|
290 ;;; ========================================================================
|
|
291 ;;; Displays files and directories when double quoted pathname is activated.
|
|
292 ;;; ========================================================================
|
|
293
|
|
294 (defib pathname ()
|
|
295 "Makes a delimited, valid pathname display the path entry.
|
|
296 Also works for delimited and non-delimited ange-ftp and efs pathnames.
|
100
|
297 Emacs Lisp library files (filenames that end in .el and .elc) are looked up
|
|
298 using the load-path directory list.
|
|
299
|
0
|
300 See `hpath:at-p' function documentation for possible delimiters.
|
|
301 See `hpath:suffixes' variable documentation for suffixes that are added to or
|
|
302 removed from pathname when searching for a valid match.
|
100
|
303 See `hpath:find' function documentation for special file display options."
|
0
|
304 (let ((path (hpath:at-p)))
|
100
|
305 (cond (path
|
|
306 (ibut:label-set path)
|
|
307 (hact 'link-to-file path))
|
|
308 ((and (fboundp 'locate-file)
|
|
309 (setq path (or (hargs:delimited "\"" "\"")
|
|
310 ;; Filenames in Info docs
|
|
311 (hargs:delimited "\`" "\'")
|
|
312 ;; Filenames in TexInfo docs
|
|
313 (hargs:delimited "@file{" "}")))
|
|
314 (string-match ".\\.el?c\\'" path))
|
|
315 (ibut:label-set path)
|
|
316 (setq path (locate-file path load-path))
|
|
317 (if path (hact 'link-to-file path))))))
|
|
318
|
0
|
319
|
|
320 ;;; ========================================================================
|
|
321 ;;; Jumps to source line associated with debugger stack frame or breakpoint
|
|
322 ;;; lines. Supports gdb, dbx, and xdb.
|
|
323 ;;; ========================================================================
|
|
324
|
|
325 (defib debugger-source ()
|
|
326 "Jumps to source line associated with debugger stack frame or breakpoint lines.
|
|
327 This works with gdb, dbx, and xdb. Such lines are recognized in any buffer."
|
|
328 (save-excursion
|
|
329 (beginning-of-line)
|
|
330 (cond ((looking-at ".+ \\(at\\|file\\) \\([^ :]+\\):\\([0-9]+\\)\\.?$")
|
|
331 ;; GDB
|
|
332 (let* ((file (buffer-substring (match-beginning 2)
|
|
333 (match-end 2)))
|
|
334 (line-num (buffer-substring (match-beginning 3)
|
|
335 (match-end 3)))
|
|
336 (but-label (concat file ":" line-num)))
|
|
337 (setq line-num (string-to-int line-num))
|
|
338 (ibut:label-set but-label)
|
|
339 (hact 'link-to-file-line file line-num)))
|
|
340 ((looking-at ".+ (file=[^\"\n]+\"\\([^\"\n]+\\)\", line=\\([0-9]+\\),")
|
|
341 ;; XEmacs assertion failure
|
|
342 (let* ((file (buffer-substring (match-beginning 1)
|
|
343 (match-end 1)))
|
|
344 (line-num (buffer-substring (match-beginning 2)
|
|
345 (match-end 2)))
|
|
346 (but-label (concat file ":" line-num)))
|
|
347 (setq line-num (string-to-int line-num))
|
|
348 (ibut:label-set but-label)
|
|
349 (hact 'link-to-file-line file line-num)))
|
|
350 ((looking-at ".+ line \\([0-9]+\\) in \"\\([^\"]+\\)\"$")
|
|
351 ;; New DBX
|
|
352 (let* ((file (buffer-substring (match-beginning 2)
|
|
353 (match-end 2)))
|
|
354 (line-num (buffer-substring (match-beginning 1)
|
|
355 (match-end 1)))
|
|
356 (but-label (concat file ":" line-num)))
|
|
357 (setq line-num (string-to-int line-num))
|
|
358 (ibut:label-set but-label)
|
|
359 (hact 'link-to-file-line file line-num)))
|
|
360 ((or (looking-at ".+ \\[\"\\([^\"]+\\)\":\\([0-9]+\\),") ;; Old DBX
|
|
361 (looking-at ".+ \\[\\([^: ]+\\): \\([0-9]+\\)\\]")) ;; HP-UX xdb
|
|
362 (let* ((file (buffer-substring (match-beginning 1)
|
|
363 (match-end 1)))
|
|
364 (line-num (buffer-substring (match-beginning 2)
|
|
365 (match-end 2)))
|
|
366 (but-label (concat file ":" line-num)))
|
|
367 (setq line-num (string-to-int line-num))
|
|
368 (ibut:label-set but-label)
|
|
369 (hact 'link-to-file-line file line-num))))))
|
|
370
|
|
371 ;;; ========================================================================
|
|
372 ;;; Jumps to source line associated with grep or compilation error messages.
|
|
373 ;;; With credit to Michael Lipp and Mike Williams for the idea.
|
|
374 ;;; ========================================================================
|
|
375
|
|
376 (defib grep-msg ()
|
|
377 "Jumps to line associated with grep or compilation error msgs.
|
|
378 Messages are recognized in any buffer."
|
|
379 (progn
|
|
380 (if (equal (buffer-name) "*compilation*")
|
|
381 (progn
|
|
382 (require 'compile)
|
|
383 ;; Make sure we have a parsed error-list
|
|
384 (if (eq compilation-error-list t)
|
|
385 (progn (compilation-forget-errors)
|
|
386 (setq compilation-parsing-end 1)))
|
|
387 (if (not compilation-error-list)
|
|
388 (save-excursion
|
|
389 (set-buffer-modified-p nil)
|
|
390 (condition-case ()
|
|
391 ;; Emacs V19 incompatibly adds two non-optional arguments
|
|
392 ;; over V18.
|
|
393 (compilation-parse-errors nil nil)
|
|
394 (error (compilation-parse-errors)))))))
|
|
395 ;; Locate and parse grep messages found in any buffer.
|
|
396 (save-excursion
|
|
397 (beginning-of-line)
|
|
398 (if (or
|
|
399 ;; UNIX C compiler and Introl 68HC11 C compiler errors
|
|
400 (looking-at "\\([^ \t\n\^M:]+\\): ?\\([0-9]+\\)[ :]")
|
|
401 ;; BSO/Tasking 68HC08 C compiler errors
|
|
402 (looking-at
|
|
403 "[a-zA-Z 0-9]+: \\([^ \t\n\^M]+\\) line \\([0-9]+\\)[ \t]*:")
|
|
404 ;; UNIX Lint errors
|
|
405 (looking-at "[^:]+: \\([^ \t\n\^M:]+\\): line \\([0-9]+\\):")
|
|
406 ;; SparcWorks C compiler errors (ends with :)
|
|
407 ;; IBM AIX xlc C compiler errors (ends with .)
|
|
408 (looking-at "\"\\([^\"]+\\)\", line \\([0-9]+\\)[:.]")
|
|
409 ;; Introl as11 assembler errors
|
|
410 (looking-at " \\*+ \\([^ \t\n\^M]+\\) - \\([0-9]+\\) ")
|
|
411 ;; perl5: ... at file.c line 10
|
|
412 (looking-at ".+ at \\([^ \t\n]+\\) line +\\([0-9]+\\)")
|
|
413 )
|
|
414 (let* ((file (buffer-substring (match-beginning 1)
|
|
415 (match-end 1)))
|
|
416 (line-num (buffer-substring (match-beginning 2)
|
|
417 (match-end 2)))
|
|
418 (but-label (concat file ":" line-num))
|
|
419 (source-loc (hbut:key-src t)))
|
|
420 (if (stringp source-loc)
|
|
421 (setq file (expand-file-name
|
|
422 file (file-name-directory source-loc))))
|
|
423 (setq line-num (string-to-int line-num))
|
|
424 (ibut:label-set but-label)
|
|
425 (hact 'link-to-file-line file line-num))))))
|
|
426
|
|
427 ;;; ========================================================================
|
|
428 ;;; Jumps to source of Emacs Lisp V19 byte-compiler error messages.
|
|
429 ;;; ========================================================================
|
|
430
|
|
431 (defib elisp-compiler-msg ()
|
|
432 "Jumps to source code for definition associated with byte-compiler error message.
|
|
433 Works when activated anywhere within an error line."
|
|
434 (if (or (equal (buffer-name) "*Compile-Log*")
|
|
435 (equal (buffer-name) "*compilation*")
|
|
436 (save-excursion
|
|
437 (and (re-search-backward "^[^ \t\n\r]" nil t)
|
|
438 (looking-at "While compiling"))))
|
|
439 (let (src buffer-p label)
|
|
440 (and (save-excursion
|
|
441 (re-search-backward
|
|
442 "^While compiling [^\t\n]+ in \\(file\\|buffer\\) \\([^ \n]+\\):$"
|
|
443 nil t))
|
|
444 (setq buffer-p
|
|
445 (equal (buffer-substring (match-beginning 1) (match-end 1))
|
|
446 "buffer")
|
|
447 src (buffer-substring (match-beginning 2) (match-end 2)))
|
|
448 (save-excursion
|
|
449 (end-of-line)
|
|
450 (re-search-backward "^While compiling \\([^ \n]+\\)\\(:$\\| \\)"
|
|
451 nil t))
|
|
452 (progn
|
|
453 (setq label (buffer-substring
|
|
454 (match-beginning 1) (match-end 1)))
|
|
455 (ibut:label-set label (match-beginning 1) (match-end 1))
|
|
456 ;; Remove prefix generated by actype and ibtype definitions.
|
|
457 (setq label (hypb:replace-match-string "[^:]+::" label "" t))
|
|
458 (hact 'link-to-regexp-match
|
|
459 (concat "^\(def[a-z \t]+" (regexp-quote label)
|
|
460 "[ \t\n\(]")
|
|
461 1 src buffer-p))))))
|
|
462
|
|
463 ;;; ========================================================================
|
|
464 ;;; Jumps to source associated with a line of output from 'patch'.
|
|
465 ;;; ========================================================================
|
|
466
|
|
467 (defib patch-msg ()
|
|
468 "Jumps to source code associated with output from the 'patch' program.
|
|
469 Patch applies diffs to source code."
|
|
470 (if (save-excursion
|
|
471 (beginning-of-line)
|
|
472 (looking-at "Patching \\|Hunk "))
|
|
473 (let ((opoint (point))
|
|
474 (file) line)
|
|
475 (beginning-of-line)
|
|
476 (cond ((looking-at "Hunk .+ at \\([0-9]+\\)")
|
|
477 (setq line (buffer-substring (match-beginning 1)
|
|
478 (match-end 1)))
|
|
479 (ibut:label-set line (match-beginning 1) (match-end 1))
|
|
480 (if (re-search-backward "^Patching file \\(\\S +\\)" nil t)
|
|
481 (setq file (buffer-substring (match-beginning 1)
|
|
482 (match-end 1)))))
|
|
483 ((looking-at "Patching file \\(\\S +\\)")
|
|
484 (setq file (buffer-substring (match-beginning 1)
|
|
485 (match-end 1))
|
|
486 line "1")
|
|
487 (ibut:label-set file (match-beginning 1) (match-end 1))))
|
|
488 (goto-char opoint)
|
|
489 (if (null file)
|
|
490 nil
|
|
491 (setq line (string-to-int line))
|
|
492 (hact 'link-to-file-line file line)))))
|
|
493
|
|
494 ;;; ========================================================================
|
|
495 ;;; Composes mail, in another window, to the e-mail address at point.
|
|
496 ;;; ========================================================================
|
|
497
|
|
498 (defib mail-address ()
|
|
499 "If on an e-mail address in a specific buffer type, mail to that address in another window.
|
|
500 Applies to the rolodex match buffer, any buffer attached to a file in
|
|
501 'rolo-file-list', or any buffer with \"mail\" or \"rolo\" (case-insensitive)
|
|
502 within its name."
|
|
503 (if (or (and (let ((case-fold-search t))
|
|
504 (string-match "mail\\|rolo" (buffer-name)))
|
|
505 ;; Don't want this to trigger in a mail/news summary buffer.
|
|
506 (not (or (hmail:lister-p) (hnews:lister-p))))
|
|
507 (if (boundp 'rolo-display-buffer)
|
|
508 (equal (buffer-name) rolo-display-buffer))
|
|
509 (and buffer-file-name
|
|
510 (boundp 'rolo-file-list)
|
|
511 (set:member (current-buffer)
|
|
512 (mapcar 'get-file-buffer rolo-file-list))))
|
|
513 (let ((address (mail-address-at-p)))
|
|
514 (if address
|
|
515 (progn
|
|
516 (ibut:label-set address (match-beginning 1) (match-end 1))
|
|
517 (hact 'mail-other-window nil address))))))
|
|
518
|
|
519 (defconst mail-address-regexp
|
|
520 "\\([_a-zA-Z][-_a-zA-Z0-9.!@+%]*@[-_a-zA-Z0-9.!@+%]+\\.[a-zA-Z][-_a-zA-Z][-_a-zA-Z]?\\|[a-zA-Z][-_a-zA-Z0-9.!+%]+@[-_a-zA-Z0-9@]+\\)\\($\\|[^a-zA-Z0-9.!@%]\\)"
|
|
521 "Regexp with group 1 matching an Internet email address.")
|
|
522
|
|
523 (defun mail-address-at-p ()
|
|
524 "Return e-mail address, a string, that point is within or nil."
|
|
525 (save-excursion
|
|
526 (skip-chars-backward "^ \t\n\^M\"\'(){}[];<>|")
|
|
527 (if (looking-at mail-address-regexp)
|
|
528 (buffer-substring (match-beginning 1) (match-end 1)))))
|
|
529
|
|
530 ;;; ========================================================================
|
|
531 ;;; Displays Info nodes when double quoted "(file)node" button is activated.
|
|
532 ;;; ========================================================================
|
|
533
|
|
534 (defib Info-node ()
|
|
535 "Makes \"(file)node\" buttons display the associated Info node."
|
|
536 (let* ((node-ref-and-pos (hbut:label-p t "\"" "\"" t))
|
|
537 (node-ref (hpath:is-p (car node-ref-and-pos) nil t)))
|
|
538 (and node-ref (string-match "([^\)]+)" node-ref)
|
|
539 (ibut:label-set node-ref-and-pos)
|
|
540 (hact 'link-to-Info-node node-ref))))
|
|
541
|
|
542 ;;; ========================================================================
|
|
543 ;;; Inserts completion into minibuffer or other window.
|
|
544 ;;; ========================================================================
|
|
545
|
|
546 (defib completion ()
|
|
547 "Inserts completion at point into minibuffer or other window."
|
|
548 (let ((completion (hargs:completion t)))
|
|
549 (and completion
|
|
550 (ibut:label-set completion)
|
|
551 (hact 'completion))))
|
|
552
|
|
553
|
|
554 (run-hooks 'hibtypes:end-load-hook)
|
|
555 (provide 'hibtypes)
|
|
556
|