Skip to content

Commit bf73086

Browse files
committed
Generalize in-buffer button completion UI; Hyperbole manual updates
1 parent 7a14688 commit bf73086

File tree

11 files changed

+287
-211
lines changed

11 files changed

+287
-211
lines changed

Changes

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
2020-02-23 Bob Weiner <[email protected]>
22

3-
* hbut.el (ibut:act): Added to interactively prompt for and activate named implicit buttons,
4-
<[name]>.
3+
* hui-menu.el (infodock-hyperbole-menu): Changed 'Activate-Button-at-Point' to 'Activate-Button-in-Buffer'
4+
and made prompt for button if not on one. This synchronizes it with the top-level 'Act' command in
5+
the Hyperbole minibuffer menu.
6+
* man/hyperbole.texi (Menus): Updated to reflect the above change.
7+
(Modeline Clicks and Drags): Added moving frames with bottommost modeline drags.
8+
9+
* hui.el: (hui:ebut-act, hui:ibut-act): Changed body to a call of hui:hbut-operate.
10+
(hui:hbut-operate): Changed to call actype:act to perform operation. Also changed to a private
11+
function.
12+
hbut.el (hbut:act): Activated only when a valid Hyperbole button symbol is given; improved error checking.
13+
14+
* hbut.el:
15+
hui.el: Changed doc strings to imperative form.
16+
17+
* hui-menu.el (infodock-hyperbole-menu): Updated Implicit-Button/Activate (renamed from Activate-at-Point).
18+
hui-mini.el (hui:menus): Updated Ibut/Act.
19+
hui.el (hui:ibut-act): Added to better mirror hui:ebut-act and replaced Ibut/Act menu items with this.
20+
21+
* hui.el (hui:hbut-act):
22+
hbut.el (hbut:act): Added interactive completion of in-buffer ebuts and ibuts.
23+
24+
* man/hyperbole.texi (Questions and Answers): Rewrote Org-mode question a bit to account for
25+
improved integration.
26+
27+
* hbut.el (ibut:act): Added to interactively prompt for and activate labeled implicit buttons.
528

629
2020-02-22 Bob Weiner <[email protected]>
730

HY-NEWS

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,29 @@
77

88
BUTTON TYPES
99

10-
- In-buffer Labels: Fixed a number of in-buffer text handling issues
11-
with the creation of explicit buttons, maximizing reuse of existing
12-
text in labels.
10+
- In-buffer Labels: Fixed a number of in-buffer text handling issues with
11+
the creation of explicit buttons, maximizing reuse of existing text in
12+
labels.
1313

14-
- link-to-file Action Type: Extended to allow file path to include
15-
either :line-num:column-num or just :line-num at the end (translated
16-
to character location within the button).
14+
- link-to-file Action Type: Extended to allow file path to include either
15+
:line-num:column-num or just :line-num at the end (translated to character
16+
location within the button).
1717

1818
DOCUMENTATION
1919

2020
- Bookmark Mode: Added Hyperbole Manual section, "Smart Key - Bookmark Mode"
2121
that allows linking to Emacs Bookmarks. See "(hyperbole)Smart Key -
2222
Bookmark Mode".
2323

24+
MENUS
25+
26+
- Activate Any Labeled Buffer Button: Hyperbole's top-level menu 'Act'
27+
command either activates any button at point or prompts for the choice of
28+
any labeled explicit or implicit button within the buffer to activate.
29+
The pulldown menu item, Activate-Button-in-Buffer, behaves the same.
30+
31+
- Org-mode in Q&A Appendix: Rewrote this section to account for improved
32+
integration.
2433

2534
===========================================================================
2635
* V7.0.9

hact.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ is returned."
445445
(defun actype:eval (actype &rest args)
446446
"Performs action formed from ACTYPE and rest of ARGS and returns value.
447447
ACTYPE may be a string containing a Lisp expression from which ACTYPE
448-
and ARGS are extracted ACTYPE may be a symbol or symbol name for
448+
and ARGS are extracted. ACTYPE may be a symbol or symbol name for
449449
either an action type or a function. Runs `action-act-hook' before
450450
performing ACTION."
451451
(let ((prefix-arg current-prefix-arg)

hbut.el

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Nil disables saving.")
3434
"Maximum length of a hyper-button label.")
3535

3636
(defun ebut:act (label)
37-
"Activates Hyperbole explicit button with LABEL from the current buffer."
37+
"Activate Hyperbole explicit button with LABEL from the current buffer."
3838
(interactive (list (hargs:read-match "Activate explicit button labeled: "
3939
(ebut:alist)
4040
nil t nil 'ebut)))
@@ -52,7 +52,7 @@ as a completion table."
5252

5353
(defun ebut:at-p (&optional start-delim end-delim)
5454
"Return explicit Hyperbole button at point or nil.
55-
Assumes point is within first line of button label, if at all.
55+
Assume point is within first line of button label, if at all.
5656
Optional START-DELIM and END-DELIM are strings that override default
5757
button delimiters."
5858
(let ((key (ebut:label-p nil start-delim end-delim)))
@@ -97,10 +97,10 @@ Return entry deleted (a list of attribute values) or nil."
9797
"Return explicit Hyperbole button symbol given by LBL-KEY and BUFFER.
9898
KEY-SRC is given when retrieving global buttons and is the full source pathname.
9999
100-
Retrieves button data, converts into a button object and returns a symbol
100+
Retrieve button data, convert into a button object and return a symbol
101101
which references the button.
102102
103-
All arguments are optional. When none are given, returns a symbol for
103+
All arguments are optional. When none are given, return a symbol for
104104
the button that point is within or nil. BUFFER defaults to the current
105105
buffer."
106106
(hattr:clear 'hbut:current)
@@ -265,14 +265,14 @@ include delimiters when INCLUDE-DELIMS is non-nil)."
265265
(hbut:map but-func ebut:start ebut:end regexp-match include-delims))
266266

267267
(defun ebut:modify (&optional lbl-key but-sym)
268-
"Modifies existing Hyperbole button from optional LBL-KEY and BUT-SYM.
268+
"Modify existing Hyperbole button from optional LBL-KEY and BUT-SYM.
269269
Defaults are the key for any button label at point and `hbut:current'.
270-
If successful, returns button's instance number except when instance
271-
number is 1, then returns t. On failure, as when button does not exist,
272-
returns nil.
270+
If successful, return button's instance number, except when instance
271+
number is 1, then return t. On failure, as when button does not exist,
272+
return nil.
273273
274-
If successful, leaves point in button data buffer, so caller should use
275-
`save-excursion'. Does not save button data buffer."
274+
If successful, leave point in button data buffer, so caller should use
275+
`save-excursion'. Do not save button data buffer."
276276
(save-excursion
277277
(let ((lbl-instance (hbdata:write lbl-key but-sym)))
278278
(run-hooks 'ebut-modify-hook)
@@ -302,7 +302,7 @@ If CURR-LABEL is nil, the text in the active region is used as the
302302
button label, if any, otherwise, an error is signaled.
303303
304304
Return instance string appended to label to form a per-buffer unique
305-
label; nil if label is already unique. Signals an error when no such
305+
label; nil if label is already unique. Signal an error when no such
306306
button is found in the current buffer."
307307
(let* ((lbl-key (ebut:label-to-key curr-label))
308308
(lbl-regexp (ebut:label-regexp lbl-key))
@@ -392,8 +392,8 @@ button is found in the current buffer."
392392

393393
(defun ebut:search (string out-buf &optional match-part)
394394
"Write explicit button lines matching STRING to OUT-BUF.
395-
Searche across all files into which the user has previously saved explicit buttons.
396-
By default, only matches for whole button labels are found; optional MATCH-PART
395+
Search across all files into which the user has previously saved explicit buttons.
396+
By default, find matches for whole button labels only; optional MATCH-PART
397397
enables partial matches."
398398
(let* ((buffers (mapcar (lambda (dir)
399399
(expand-file-name hattr:filename dir))
@@ -549,7 +549,7 @@ Insert INSTANCE-FLAG after END, before ending delimiter."
549549
"File that stores globally accessible Hyperbole buttons, accessed by name.")
550550

551551
(defun gbut:act (label)
552-
"Activates Hyperbole global button with LABEL."
552+
"Activate Hyperbole global button with LABEL."
553553
(interactive (list (hargs:read-match "Activate global button labeled: "
554554
(mapcar 'list (gbut:label-list))
555555
nil t nil 'gbut)))
@@ -566,16 +566,16 @@ Insert INSTANCE-FLAG after END, before ending delimiter."
566566
(defun gbut:get (&optional lbl-key)
567567
"Return global Hyperbole button symbol given by optional LBL-KEY if found in gbut:file.
568568
569-
Retrieves any button data, converts into a button object and returns a symbol
569+
Retrieve any button data, convert into a button object and return a symbol
570570
which references the button.
571571
572-
All arguments are optional. When none are given, returns a symbol for
572+
All arguments are optional. When none are given, return a symbol for
573573
the button that point is within or nil."
574574
(or (ebut:get lbl-key nil gbut:file)
575575
(ibut:get lbl-key nil gbut:file)))
576576

577577
(defun gbut:help (label)
578-
"Displays help for Hyperbole global button with LABEL."
578+
"Display help for Hyperbole global button with LABEL."
579579
(interactive (list (hargs:read-match "Report on global button labeled: "
580580
(mapcar 'list (gbut:label-list))
581581
nil t nil 'hbut)))
@@ -759,12 +759,19 @@ others who use a different value!")
759759
(defun hbut:act (&optional hbut)
760760
"Perform action for optional explicit or implicit Hyperbole button symbol HBUT.
761761
Default is 'hbut:current."
762+
(interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole button: "
763+
(nconc (ebut:alist) (ibut:alist))
764+
nil t nil 'hbut))))
762765
(unless hbut
763766
(setq hbut 'hbut:current))
764-
(when hbut
765-
(apply hrule:action
766-
(hattr:get hbut 'actype)
767-
(hattr:get hbut 'args))))
767+
(cond ((hbut:is-p hbut)
768+
(apply hrule:action
769+
(hattr:get hbut 'actype)
770+
(hattr:get hbut 'args)))
771+
((and hbut (symbolp hbut))
772+
(hypb:error "(hbut:act): Symbol, %s, has invalid Hyperbole button attributes:\n %S" hbut (hattr:list hbut)))
773+
(t
774+
(hypb:error "(hbut:act): Invalid Hyperbole button: %s" hbut))))
768775

769776
(defun hbut:action (hbut)
770777
"Return appropriate action for Hyperbole button symbol HBUT."
@@ -786,8 +793,8 @@ Then use (hbut:act) to activate the button."
786793

787794
(defun hbut:comment (start end)
788795
"Comment button label spanning region START to END in current buffer.
789-
Usees buffer commenting grammar, if any, otherwise doesn't comment.
790-
Ignores email-related buffers."
796+
Use buffer commenting grammar, if any, otherwise don't comment.
797+
Ignore email-related buffers."
791798
(save-excursion
792799
(if (and comment-start (not (hmail:mode-is-p))
793800
(not (memq major-mode '(mail-mode message-mode))))
@@ -881,8 +888,8 @@ nil. BUFFER defaults to the current buffer."
881888

882889
(defun hbut:key-src (&optional full)
883890
"Return key source (usually unqualified) for current Hyperbole button.
884-
Also sets current buffer to key source.
885-
With optional FULL when source is a pathname, the full pathname is returned."
891+
Als sets current buffer to key source.
892+
With optional FULL when source is a pathname, return the full pathname."
886893
(let ((src (cond ((hmail:mode-is-p) (current-buffer))
887894
;; If buffer represents the output of a document
888895
;; formatter, e.g. an Info document produced from a
@@ -959,7 +966,7 @@ represent the output of particular document formatters."
959966
src)))
960967

961968
(defun hbut:key-to-label (lbl-key)
962-
"Unnormalizes LBL-KEY and returns a label string for display."
969+
"Unnormalize LBL-KEY and return a label string for display."
963970
(if lbl-key
964971
(let* ((pos 0) (len (length lbl-key)) (lbl) c)
965972
(while (< pos len)
@@ -984,13 +991,13 @@ represent the output of particular document formatters."
984991

985992
(defun hbut:label-p (&optional as-label start-delim end-delim pos-flag two-lines-flag)
986993
"Return key for the Hyperbole button label that point is within, else nil.
987-
Assumes point is within the first line of any button label. All
988-
following arguments are optional. If AS-LABEL is non-nil, label
989-
is returned rather than the key derived from the label.
994+
Assume point is within the first line of any button label. All
995+
following arguments are optional. If AS-LABEL is non-nil, return
996+
the label rather than the key derived from the label.
990997
START-DELIM and END-DELIM are strings that override default
991-
button delimiters. With POS-FLAG non-nil, returns list of
998+
button delimiters. With POS-FLAG non-nil, return list of
992999
label-or-key, but-start-position, but-end-position. Positions
993-
include delimiters. With TWO-LINES-FLAG non-nil, constrains
1000+
include delimiters. With TWO-LINES-FLAG non-nil, constrain
9941001
label search to two lines."
9951002
(or (ebut:label-p as-label start-delim end-delim pos-flag two-lines-flag)
9961003
(ibut:label-p as-label start-delim end-delim pos-flag two-lines-flag)))
@@ -1024,10 +1031,10 @@ label; these default to `ebut:start' and `ebut:end'."
10241031
(setq regexp (concat regexp sep0 (regexp-quote (or end-delim ebut:end))))))))
10251032

10261033
(defun hbut:label-to-key (label)
1027-
"Normalizes LABEL for use as a Hyperbole button key and returns key.
1028-
Eliminates any fill prefix in the middle of the label, replaces `_' with
1029-
`__', removes leading and trailing whitespace and replaces each other
1030-
whitespace sequence with `_'."
1034+
"Normalize LABEL for use as a Hyperbole button key and return key.
1035+
Eliminate any fill prefix in the middle of the label, replace `_' with
1036+
`__', remove leading and trailing whitespace and replace all other
1037+
whitespace sequences with `_'."
10311038
(when label
10321039
(setq label (hbut:fill-prefix-remove label)
10331040
;; Remove leading and trailing space.
@@ -1038,12 +1045,12 @@ whitespace sequence with `_'."
10381045

10391046
(defun hbut:map (but-func &optional start-delim end-delim
10401047
regexp-match include-delims)
1041-
"Applies BUT-FUNC to a set of Hyperbole buttons in the visible part of the current buffer.
1048+
"Apply BUT-FUNC to a set of Hyperbole buttons in the visible part of the current buffer.
10421049
The set of buttons are those whose labels are delimited by optional START-DELIM and
10431050
END-DELIM and that match any optional REGEXP-MATCH.
10441051
10451052
START-DELIM defaults to ebut:start; END-DELIM defaults to ebut:end.
1046-
If END-DELIM is a symbol, e.g. t, then START-DELIM is taken as a regular
1053+
If END-DELIM is a symbol, e.g. t, then treat START-DELIM as a regular
10471054
expression which matches an entire button string.
10481055
10491056
BUT-FUNC must take precisely three arguments: the button label, the
@@ -1167,7 +1174,7 @@ Return number of buttons reported on or nil if none."
11671174

11681175
(defun hbut:source (&optional full)
11691176
"Return Hyperbole source buffer or file given at point.
1170-
If a file, always returns a full path if optional FULL is non-nil."
1177+
If a file, always return a full path if optional FULL is non-nil."
11711178
(goto-char (match-end 0))
11721179
(cond ((looking-at "#<buffer \"?\\([^\n\"]+\\)\"?>")
11731180
(get-buffer (match-string 1)))
@@ -1228,7 +1235,7 @@ source file for the buttons in the menu, if any.")
12281235

12291236

12301237
(defun ibut:act (label)
1231-
"Activates Hyperbole implicit button with <[LABEL]> from the current buffer."
1238+
"Activate Hyperbole implicit button with <[LABEL]> from the current buffer."
12321239
(interactive (list (hargs:read-match "Activate implicit button labeled: "
12331240
(ibut:alist)
12341241
nil t nil 'ibut)))
@@ -1329,7 +1336,7 @@ KEY-SRC is given when retrieving global buttons and is the full source pathname.
13291336
13301337
Return a symbol which references the button.
13311338
1332-
All arguments are optional. When none are given, returns a
1339+
All arguments are optional. When none are given, return a
13331340
symbol for the button or button label that point is within or
13341341
nil. BUFFER defaults to the current buffer."
13351342
(hattr:clear 'hbut:current)
@@ -1375,15 +1382,15 @@ Map over portion of buffer visible under any current restriction.
13751382
BUT-FUNC must take precisely three arguments: the button label, the
13761383
start position of the delimited button label and its end position (positions
13771384
include delimiters when INCLUDE-DELIMS is non-nil).
1378-
If END-DELIM is a symbol, e.g. t, then START-DELIM is taken as a regular
1385+
If END-DELIM is a symbol, e.g. t, then treat START-DELIM as a regular
13791386
expression which matches an entire button string."
13801387
(hbut:map but-func ibut:label-start ibut:label-end))
13811388

13821389
(defun ibut:rename (old-lbl new-lbl)
1383-
"Modifies a label preceding a Hyperbole implicit button in the current buffer given by LBL-KEY.
1384-
Signals an error when no such button is found in the current buffer.
1390+
"Modify a label preceding a Hyperbole implicit button in the current buffer given by LBL-KEY.
1391+
Signal an error when no such button is found in the current buffer.
13851392
1386-
Leaves point at the start of the button label which may be elsewhere
1393+
Leave point at the start of the button label which may be elsewhere
13871394
than the current point; callers should use `save-excursion` to retain
13881395
current."
13891396
;; !! Need to handle adding instances to labels, similar to ebut:operate.
@@ -1401,7 +1408,7 @@ current."
14011408
This is the normalized key form of an optional label that may
14021409
precede an implicit button. Use `ibut:at-p' instead to test if
14031410
point is on either the implicit button text itself or the label.
1404-
Assumes point is within the first line of any button label.
1411+
Assume point is within the first line of any button label.
14051412
14061413
All following arguments are optional. If AS-LABEL is non-nil,
14071414
label is returned rather than the key derived from the label.

hui-menu.el

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,11 @@ REBUILD-FLAG is non-nil, in which case the menu is rebuilt."
317317
;; Delete Hyperbole menu from all menubars.
318318
(hui-menu-remove Hyperbole)
319319
;;
320-
;; Remove Hyperbole button comment from future
321-
;; outgoing mail.
320+
;; Remove Hyperbole button comment from future outgoing mail.
322321
(if (boundp 'smail:comment) (setq smail:comment nil)))
323322
t]
324323
"----"
325-
["Activate-Button-at-Point" hui:hbut-current-act
326-
(hbut:is-p (hbut:at-p))]
324+
["Activate-Button-in-Buffer" hui:hbut-act t]
327325
["Back-to-Prior-Location" (hhist:remove current-prefix-arg)
328326
(and (boundp '*hhist*) *hhist*)]
329327
'("Button-File"
@@ -405,8 +403,8 @@ REBUILD-FLAG is non-nil, in which case the menu is rebuilt."
405403
'("Implicit-Button"
406404
["Manual" (id-info "(hyperbole)Implicit Buttons") t]
407405
"----"
408-
["Activate-at-Point" hui:hbut-current-act t]
409-
["Delete-Type" (hui:htype-delete 'ibtypes) t]
406+
["Activate" hui:ibut-act t]
407+
["Delete-Type" (hui:htype-delete 'ibtypes) t]
410408
["Help" hui:hbut-help t]
411409
["Label" hui:ibut-label-create t]
412410
["Rename" hui:ibut-rename t]

hui-mini.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ constructs. If not given, the top level Hyperbole menu is used."
387387
(delq nil
388388
(list
389389
'("Act" hui:hbut-act
390-
"Activates button at point or prompts for explicit button.")
390+
"Activate button at point or prompt for a labeled button in buffer.")
391391
'("Butfile/" (menu . butfile)
392392
"Quick access button files menus.")
393393
'("Cust/" (menu . cust)
@@ -575,7 +575,8 @@ constructs. If not given, the top level Hyperbole menu is used."
575575
))
576576
'(ibut .
577577
(("IButton>")
578-
("Act" hui:hbut-current-act "Activates implicit button at point.")
578+
("Act" hui:ibut-act
579+
"Activates implicit button at point or prompts for labeled implicit button to activate.")
579580
("DeleteIButType" (hui:htype-delete 'ibtypes)
580581
"Deletes specified button type.")
581582
("Help" hui:hbut-help "Reports on button's attributes.")

0 commit comments

Comments
 (0)