diff options
Diffstat (limited to 'hactypes.el')
| -rw-r--r-- | hactypes.el | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/hactypes.el b/hactypes.el index bfe03fc..e082860 100644 --- a/hactypes.el +++ b/hactypes.el @@ -29,8 +29,8 @@ (key-regexp (concat "^[*]*[ \t]*\\\[" (ebut:key-to-label key) "\\\]")) citation) (if (save-excursion - (goto-char (point-min)) - (setq citation (re-search-forward key-regexp nil t))) + (goto-char (point-max)) + (setq citation (re-search-backward key-regexp nil t))) (progn (hpath:display-buffer (current-buffer)) (goto-char citation) (beginning-of-line)) @@ -250,7 +250,7 @@ Use `link-to-file' instead for a permanent link." (hpath:find directory)) (defact link-to-ebut (key-file key) - "Performs action given by another explicit button, specified by KEY-FILE and KEY." + "Performs action given by an explicit button, specified by KEY-FILE and KEY." (interactive (let (but-file but-lbl) (while (cond ((setq but-file @@ -272,11 +272,12 @@ Use `link-to-file' instead for a permanent link." nil nil nil 'ebut))) (beep)) (ebut:label-to-key but-lbl))))) - (or (called-interactively-p 'interactive) - (setq key-file (hpath:validate (hpath:substitute-value key-file)))) + (unless (called-interactively-p 'interactive) + (setq key-file (hpath:validate (hpath:substitute-value key-file)))) (let ((but (ebut:get key (find-file-noselect key-file)))) (if but (hbut:act but) - (hypb:error "(link-to-ebut): No button `%s' in `%s'." (ebut:key-to-label key) + (hypb:error "(link-to-ebut): No button `%s' in `%s'." + (ebut:key-to-label key) key-file)))) (defact link-to-elisp-doc (symbol) @@ -351,6 +352,24 @@ the window." (hpath:find-line path line-num)) (move-to-column column-num))) +(defact link-to-gbut (key) + "Performs an action given by an existing global button, specified by KEY." + (interactive + (let ((gbut-file (hpath:validate (hpath:substitute-value gbut:file))) + but-lbl) + (if (not (file-readable-p gbut-file)) + (hypb:error "(link-to-gbut): You cannot read `%s'." gbut-file) + (list (progn + (find-file-noselect gbut-file) + (while (string-equal "" (setq but-lbl + (hargs:read-match + "Global button to link to: " + (mapcar 'list (gbut:label-list)) + nil t nil 'gbut))) + (beep)) + (hbut:label-to-key but-lbl)))))) + (gbut:act (hbut:key-to-label key))) + (defact link-to-Info-index-item (index-item) "Displays an Info index INDEX-ITEM cross-reference. INDEX-ITEM must be a string of the form \"(filename)item-name\". During @@ -373,6 +392,37 @@ available. Filename may be given without the .info suffix." (id-info string) (hypb:error "(link-to-Info-node): Invalid Info node: `%s'" string))) +(defact link-to-ibut (key &optional key-file point) + "Performs an action given by an implicit button, specified by KEY-FILE, KEY and optional POINT. +When creating the button, point must be on the implicit button to which to link +and its buffer must have a file attached." + (interactive + (let ((ibut-key (ibut:at-p t))) + (if (and ibut-key buffer-file-name) + (list ibut-key buffer-file-name (point)) + ;; When not on an ibut and moddifying the link, use existing arguments + (if (and (boundp 'defaults) (listp defaults)) + defaults + (list nil nil nil))))) + (if key-file + (or (called-interactively-p 'interactive) + (null key-file) + (setq key-file (hpath:validate (hpath:substitute-value key-file)))) + (setq key-file buffer-file-name)) + (let (but) + (save-excursion + (save-restriction + (when key-file + (set-buffer (find-file-noselect key-file))) + (widen) + (if (integerp point) (goto-char (min point (point-max)))) + (setq but (ibut:to key)))) + (if but + (hbut:act but) + (hypb:error "(link-to-ibut): No button `%s' in `%s'." + (ibut:key-to-label key) + (or key-file (buffer-name)))))) + (defact link-to-kcell (file cell-ref) "Displays FILE with kcell given by CELL-REF at window top. See documentation for `kcell:ref-to-id' for valid cell-ref formats. |
