[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/hyperbole-lexbind 0829631 13/20: Fix small logic errors i
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/hyperbole-lexbind 0829631 13/20: Fix small logic errors in new e/g/ilink functions |
Date: |
Wed, 14 Aug 2019 04:30:23 -0400 (EDT) |
branch: scratch/hyperbole-lexbind
commit 0829631c9c2485d78b6f588b41d1f0c54b00a119
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>
Fix small logic errors in new e/g/ilink functions
---
Changes | 6 ++++++
hactypes.el | 36 ++++++++++++++++++++----------------
hbut.el | 4 ++--
hibtypes.el | 15 +++++++++------
4 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/Changes b/Changes
index 0815d4e..1712e2d 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,9 @@
+2019-07-14 Bob Weiner <address@hidden>
+
+* hibtypes.el (link-to-ebut, link-to-gbut, link-to-ibut):
+ hactypes.el (link-to-ibut):
+ hbut.el (ibut:to): Fixed small logic errors with lbl-keys and save-excursion
in these functions.
+
2019-07-13 Bob Weiner <address@hidden>
* hsys-org.el (org-set-ibut-label): Added and used in org-mode ibtype.
diff --git a/hactypes.el b/hactypes.el
index d227faa..911a1c7 100644
--- a/hactypes.el
+++ b/hactypes.el
@@ -392,29 +392,33 @@ 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-file key &optional point)
+(defact link-to-ibut (key &optional key-file point)
"Performs 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 buffer-file-name ibut-key (point))
+ (list ibut-key buffer-file-name (point))
(list nil nil nil))))
- (or (called-interactively-p 'interactive)
- (setq key-file (hpath:validate (hpath:substitute-value key-file))))
- (let (but)
- (if (and key-file
- (save-excursion
- (save-restriction
- (find-file-noselect key-file)
- (widen)
- (if (integerp point) (goto-char (min point (point-max))))
- (setq but (ibut:to key)))))
- (hbut:act but)
- (hypb:error "(link-to-ibut): No button `%s' in `%s'."
- (ibut:key-to-label key)
- key-file))))
+ (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))
+ (save-excursion
+ (save-restriction
+ (let (but)
+ (when key-file
+ (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.
diff --git a/hbut.el b/hbut.el
index cc71510..c927647 100644
--- a/hbut.el
+++ b/hbut.el
@@ -1309,11 +1309,11 @@ move to the first occurrence of the button."
(forward-line 0)
;; re-search forward
(while (and (not found) (re-search-forward regexp nil t))
- (setq pos (goto-char (match-beginning 0))
+ (setq pos (match-beginning 0)
found (equal (ibut:at-p t) lbl-key)))
;; re-search backward
(while (and (not found) (re-search-backward regexp nil t))
- (setq pos (goto-char (match-beginning 0))
+ (setq pos (match-beginning 0)
found (equal (ibut:at-p t) lbl-key))))
(when found
(goto-char pos)
diff --git a/hibtypes.el b/hibtypes.el
index dd09470..c3eefad 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -642,12 +642,13 @@ The explicit button's action is executed in the context
of the current buffer.
Recognizes the format '<elink:' <button label> '>', e.g. <elink:
project-list>."
(let* ((label-key-start-end (hbut:label-p nil elink:start elink:end t t))
- (lbl-key (nth 0 label-key-start-end))
+ (ebut-key (nth 0 label-key-start-end))
+ (lbl-key (and ebut-key (concat "elink_" (nth 0 label-key-start-end))))
(start-pos (nth 1 label-key-start-end))
(end-pos (nth 2 label-key-start-end)))
(when lbl-key
(ibut:label-set (ebut:key-to-label lbl-key) start-pos end-pos)
- (hact 'link-to-ebut lbl-key))))
+ (hact 'link-to-ebut ebut-key))))
(defconst glink:start "<glink:"
"String matching the start of a link to a Hyperbole global button.")
@@ -660,12 +661,13 @@ The global button's action is executed in the context of
the current buffer.
Recognizes the format '<glink:' <button label> '>', e.g. <glink: open todos>."
(let* ((label-key-start-end (hbut:label-p nil glink:start glink:end t t))
- (lbl-key (nth 0 label-key-start-end))
+ (gbut-key (nth 0 label-key-start-end))
+ (lbl-key (and gbut-key (concat "glink_" (nth 0 label-key-start-end))))
(start-pos (nth 1 label-key-start-end))
(end-pos (nth 2 label-key-start-end)))
(when lbl-key
(ibut:label-set (ebut:key-to-label lbl-key) start-pos end-pos)
- (hact 'link-to-gbut lbl-key))))
+ (hact 'link-to-gbut gbut-key))))
(defconst ilink:start "<ilink:"
"String matching the start of a link to a Hyperbole implicit button.")
@@ -678,12 +680,13 @@ The implicit button's action is executed in the context
of the current buffer.
Recognizes the format '<ilink:' <button label> '>', e.g. <ilink: my sequence
of keys>."
(let* ((label-key-start-end (ibut:label-p nil ilink:start ilink:end t t))
- (lbl-key (nth 0 label-key-start-end))
+ (ibut-key (nth 0 label-key-start-end))
+ (lbl-key (and ibut-key (concat "ilink_" (nth 0 label-key-start-end))))
(start-pos (nth 1 label-key-start-end))
(end-pos (nth 2 label-key-start-end)))
(when lbl-key
(ibut:label-set (ibut:key-to-label lbl-key) start-pos end-pos)
- (hact 'link-to-ibut lbl-key))))
+ (hact 'link-to-ibut ibut-key))))
;;; ========================================================================
;;; Jumps to source line associated with ipython, ripgreb, grep or
- [elpa] scratch/hyperbole-lexbind updated (98a5ecb -> 6e555e7), Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind a65ee22 03/20: Small coding improvements, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 91e8a73 02/20: Add texinfo pathname section references; improve internal image links, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind e1a95cc 04/20: Improve paragraph filling to match newer Emacs versions, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 60d51ad 12/20: Remove last references to XEmscs and xterm used under Emacs 18, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind af55195 05/20: Make Action Key handle bi-directional jumping for Org mode radio target and internal links, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 36e4724 01/20: 7.0.3a bug fixes; add link-to-ibut, link-to-gbut, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind e647502 18/20: BSD zgrep support for Hyperbole grep command, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 0829631 13/20: Fix small logic errors in new e/g/ilink functions,
Stefan Monnier <=
- [elpa] scratch/hyperbole-lexbind b128464 06/20: Update Changes and add 7.0.3 release message to HY-ANNOUNCE, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 332ef33 19/20: V7.0.3b test release: Basic DEMO updates, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind c547ad4 10/20: Merge branch '7.0.3a' into prepare-pr-for-merging, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 131295e 07/20: Remove conditionals on xemacs, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind ff0f602 11/20: Merge pull request #11 from matsl/prepare-pr-for-merging, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind da8f3fa 09/20: Add labeled implicit buttons, in-buffer links to g/e/ibuts, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 9ad2bf0 08/20: Remove all featurep checks on xemacs and emacs, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 21c7432 15/20: Most changes for 7.0.3a release, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind f38ee21 14/20: 7.0.3a changes for creating and modifying ibut labels, small fixes, Stefan Monnier, 2019/08/14
- [elpa] scratch/hyperbole-lexbind 6e555e7 20/20: Merge remote-tracking branch 'hyperbole/master' into externals/hyperbole, Stefan Monnier, 2019/08/14