[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 7ef5033: kotl-mode and button creations fixes
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 7ef5033: kotl-mode and button creations fixes |
Date: |
Wed, 12 May 2021 01:57:08 -0400 (EDT) |
branch: externals/hyperbole
commit 7ef5033eab960f7ec9610bd7d93de111717ce221
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
kotl-mode and button creations fixes
---
ChangeLog | 23 +++++++++++++++
hbdata.el | 40 +++++++++++++-------------
hbut.el | 83 +++++++++++++++++++++++++++---------------------------
hib-kbd.el | 28 ++++++++++++------
hui.el | 67 ++++++++++++++++++++++++++-----------------
kotl/kotl-mode.el | 32 +++++++++++----------
kotl/kview.el | 2 ++
man/hyperbole.texi | 4 +--
8 files changed, 167 insertions(+), 112 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ad6e99b..69c388d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2021-05-11 Bob Weiner <rsw@gnu.org>
+* kotl/kotl-mode.el (kotl-mode:pre-self-insert-command):
+ kotl/kview.el (kcell-view:previous-kcell): Force to valid
+ position before moving. This fixes promotion/demotion bug.
+
+* hib-kbd.el (kbd-key, kbd-key:act): Interactively
+ allow for a key series, not just a single bound
+ key sequence.
+ (kbd-key:execute): Add to programmatically
+ or interactively execute a non-normalized key sequence
+ stored in a string. Also, improve library commentary
+ and mention this new command.
+
+* hbut.el (ebut:operate): Fix error that could fail to
+ delimit a new ebut.
+
+* hbdata.el (hbdata:delete-entry, hbdata:to-entry): Change
+ partial 'if' to 'when'.
+
+* hui.el (hui:ebut-unmark): Document prefix arg and handle
+ null but-key argument utilizing button at point, if any.
+ Also, fix removal of any single digit instance string
+ in button text. Clarify let var naming and usage.
+
* test/demo-tests.el (demo-org-hide-header-test): Force full
Smart Key functionality in Org mode to ensure test always
works correctly.
diff --git a/hbdata.el b/hbdata.el
index 4331e14..73548e3 100644
--- a/hbdata.el
+++ b/hbdata.el
@@ -258,22 +258,23 @@ If the hbdata buffer is blank/empty, kill it and remove
the associated file."
(kill))
(beginning-of-line)
(hbdata:delete-entry-at-point)
- (if (looking-at empty-file-entry)
- (let ((end (point))
- (empty-hbdata-file "[ \t\n\r]*\\'"))
- (forward-line -1)
- (if (eq (following-char) ?\")
- ;; Last button entry for filename, so del filename.
- (progn (forward-line -1) (delete-region (point) end)))
- (save-excursion
- (goto-char (point-min))
- (if (looking-at empty-hbdata-file)
- (setq kill t)))
- (if kill
- (let ((fname buffer-file-name))
- (erase-buffer) (save-buffer) (kill-buffer nil)
- (hbmap:dir-remove (file-name-directory fname))
- (delete-file fname))))))))
+ (when (looking-at empty-file-entry)
+ (let ((end (point))
+ (empty-hbdata-file "[ \t\n\r]*\\'"))
+ (forward-line -1)
+ (when (eq (following-char) ?\")
+ ;; Last button entry for filename, so del filename.
+ (forward-line -1)
+ (delete-region (point) end))
+ (save-excursion
+ (goto-char (point-min))
+ (when (looking-at empty-hbdata-file)
+ (setq kill t)))
+ (when kill
+ (let ((fname buffer-file-name))
+ (erase-buffer) (save-buffer) (kill-buffer nil)
+ (hbmap:dir-remove (file-name-directory fname))
+ (delete-file fname))))))))
lbl-key key-src directory))
(defun hbdata:delete-entry-at-point ()
@@ -294,10 +295,9 @@ but-key."
but-key key-src directory 'create instance)))
(hbdata:to-entry-buf key-src directory)
(forward-line 1)
- (if pos-entry-cons
- (progn
- (goto-char (car pos-entry-cons))
- (cdr pos-entry-cons)))))
+ (when pos-entry-cons
+ (goto-char (car pos-entry-cons))
+ (cdr pos-entry-cons))))
;;; ************************************************************************
;;; Private functions
diff --git a/hbut.el b/hbut.el
index 1d40a15..fa88322 100644
--- a/hbut.el
+++ b/hbut.el
@@ -314,7 +314,8 @@ button is found in the current buffer."
(lbl-regexp (ebut:label-regexp lbl-key))
(modify new-label)
(instance-flag))
- (or new-label (setq new-label curr-label))
+ (unless new-label
+ (setq new-label curr-label))
(hattr:set 'hbut:current 'lbl-key (ebut:label-to-key new-label))
(save-excursion
(when (setq instance-flag
@@ -341,47 +342,47 @@ button is found in the current buffer."
instance-flag))
lbl-regexp 'include-delims))
(at-but)
- ((hypb:error "(ebut:operate): No button matching: %s"
curr-label))))
-
- ;; Add a new button recording its start and end positions
- (let (start end mark prev-point buf-lbl)
- (cond ((not curr-label)
- (setq start (point))
- (insert new-label)
- (setq end (point)))
- ((and (hmouse-use-region-p)
- (if (hyperb:stack-frame
- '(hui:ebut-create hui:ebut-edit
- hui:ebut-modify hui:gbut-create
- hui:gbut-modify
hui:link-create ebut:program))
- ;; Ignore action-key-depress-prev-point
- (progn (setq mark (marker-position
(hypb:mark-marker t))
- start (region-beginning)
- end (region-end)
- buf-lbl (buffer-substring start end))
- (equal buf-lbl curr-label))
- ;; Utilize any action-key-depress-prev-point
- (progn (setq mark (marker-position
(hypb:mark-marker t)))
- (setq prev-point (and
action-key-depress-prev-point
- (marker-position
action-key-depress-prev-point)))
- (setq start (if (and prev-point mark (<=
prev-point mark))
- prev-point
- (region-beginning))
- end (if (and prev-point mark (>
prev-point mark))
+ ((hypb:error "(ebut:operate): No button matching: %s"
curr-label)))))
+
+ ;; Add a new button recording its start and end positions
+ (let (start end mark prev-point buf-lbl)
+ (cond ((not curr-label)
+ (setq start (point))
+ (insert new-label)
+ (setq end (point)))
+ ((and (hmouse-use-region-p)
+ (if (hyperb:stack-frame
+ '(hui:ebut-create hui:ebut-edit
+ hui:ebut-modify hui:gbut-create
+ hui:gbut-modify
hui:link-create ebut:program))
+ ;; Ignore action-key-depress-prev-point
+ (progn (setq mark (marker-position
(hypb:mark-marker t))
+ start (region-beginning)
+ end (region-end)
+ buf-lbl
(buffer-substring-no-properties start end))
+ (equal buf-lbl curr-label))
+ ;; Utilize any action-key-depress-prev-point
+ (progn (setq mark (marker-position (hypb:mark-marker
t)))
+ (setq prev-point (and
action-key-depress-prev-point
+ (marker-position
action-key-depress-prev-point)))
+ (setq start (if (and prev-point mark (<=
prev-point mark))
prev-point
- (region-end))
- buf-lbl (buffer-substring start end))
- (equal buf-lbl curr-label))))
- nil)
- ((progn (when start (goto-char start))
- (looking-at (regexp-quote curr-label)))
- (setq start (point)
- end (match-end 0)))
- (t (setq start (point))
- (insert curr-label)
- (setq end (point))))
- (ebut:delimit start end instance-flag)
- (goto-char start)))
+ (region-beginning))
+ end (if (and prev-point mark (>
prev-point mark))
+ prev-point
+ (region-end))
+ buf-lbl (buffer-substring-no-properties
start end))
+ (equal buf-lbl curr-label))))
+ nil)
+ ((progn (when start (goto-char start))
+ (looking-at (regexp-quote curr-label)))
+ (setq start (point)
+ end (match-end 0)))
+ (t (setq start (point))
+ (insert curr-label)
+ (setq end (point))))
+ (ebut:delimit start end instance-flag)
+ (goto-char start))
;; Append any instance-flag string to the button label
(when (stringp instance-flag)
diff --git a/hib-kbd.el b/hib-kbd.el
index 723b30d..c9f66cc 100644
--- a/hib-kbd.el
+++ b/hib-kbd.el
@@ -11,17 +11,21 @@
;;
;;; Commentary:
;;
-;; A press of the Action Key on any sequence of keys delimited by braces
-;; executes its command binding or Hyperbole minibuffer menu binding.
+;; A press of the Action Key on any series of key sequences delimited by
+;; curly braces executes all of the associated commands. Key sequences
+;; can include Hyperbole minibuffer menu sequences.
;;
-;; A press of the Assist Key on any sequence of keys delimited by braces
-;; displays the documentation for it.
+;; A press of the Assist Key on any series of key sequences delimited by
+;; curly braces displays the documentation for it.
;;
;; Sequences of keys should be in human readable string form with spaces
;; between each key, may contain any number of individual key sequences
;; and the whole thing should be delimited by braces, e.g. {M-x apropos
;; RET hyperbole RET}. Forms such as {\C-b}, {\^b}, and {^b} will not be
;; recognized.
+;;
+;; Programmatically, to execute a key series given as a string, use:
+;; (kbd-key:execute "{key series}").
;;; Code:
;;; ************************************************************************
@@ -64,7 +68,7 @@ Each key sequence within KEY-SERIES must be a string of one
of the following:
or a valid key sequence together with its interactive arguments.
Return t if the sequence appears to be valid, else nil."
- (interactive "kKey sequence to execute (no {}): ")
+ (interactive "sKey series to execute (no {}): ")
(kbd-key:act key-series))
(defib kbd-key ()
@@ -124,9 +128,9 @@ Any key sequence must be a string of one of the following:
;;; ************************************************************************
(defun kbd-key:act (key-series)
- "Execute the command binding for normalized KEY-SERIES.
-Returns t if KEY-SERIES has a binding, else nil."
- (interactive "kKeyboard key to execute (no {}): ")
+ "Execute the normalized KEY-SERIES.
+Return t if KEY-SERIES appears valid, else nil."
+ (interactive "sKey series to execute (no {}): ")
(setq current-prefix-arg nil) ;; Execution of the key-series may set it.
(let ((binding (kbd-key:binding key-series)))
(cond ((null binding)
@@ -139,6 +143,14 @@ Returns t if KEY-SERIES has a binding, else nil."
t)
(t (call-interactively binding) t))))
+(defun kbd-key:execute (key-series)
+ "Execute a possibly non-normalized KEY-SERIES with or without curly brace
delimiters.
+Return t if KEY-SERIES is a valid key series that is executed, else nil."
+ (interactive "sKey series to execute: ")
+ (when (and key-series
+ (setq key-series (kbd-key:is-p key-series)))
+ (hact #'kbd-key:act key-series)))
+
(defun kbd-key:execute-special-series (key-series)
"Execute key series."
(if (memq (key-binding [?\M-x]) #'(execute-extended-command counsel-M-x))
diff --git a/hui.el b/hui.el
index 0a4a17d..4cb49d0 100644
--- a/hui.el
+++ b/hui.el
@@ -918,14 +918,15 @@ within."
(ebut:delete ebut)
(hypb:error "(ebut-delete): No valid %s button in %s"
(ebut:key-to-label but-key) buf)))
- (progn (set-buffer buf)
- (if interactive
- (progn
- (call-interactively 'hui:ebut-unmark)
- (message "Button deleted."))
- (hui:ebut-unmark but-key key-src))
- (when (hmail:reader-p) (hmail:msg-narrow))
- (message "Button '%s' deleted." (ebut:key-to-label but-key)))
+ (with-current-buffer buf
+ (if interactive
+ (progn
+ (call-interactively 'hui:ebut-unmark)
+ (message "Button deleted."))
+ (hui:ebut-unmark but-key key-src))
+ (when (hmail:reader-p)
+ (hmail:msg-narrow))
+ (message "Button '%s' deleted." (ebut:key-to-label but-key)))
(hypb:error "(ebut-delete): You may not delete buttons from this
buffer"))))
(defun hui:ebut-delimit (start end instance-str)
@@ -943,49 +944,63 @@ within."
(cons actype args))))
(defun hui:ebut-unmark (&optional but-key key-src directory)
- "Remove delimiters from button given by BUT-KEY in KEY-SRC of DIRECTORY.
-All args are optional, the current button and buffer file are the defaults."
+ "Remove delimiters and any instance number from button given by BUT-KEY in
KEY-SRC of DIRECTORY.
+All args are optional, the current button and buffer file are the defaults.
+
+With a prefix argument, also delete the button text between the delimiters."
(interactive)
(let ((form (lambda ()
- (let ((buffer-read-only) start end)
- (setq start (match-beginning 0)
- end (match-end 0))
+ (let ((buffer-read-only) start-delim-pos end-delim-pos text-end)
+ (setq start-delim-pos (match-beginning 0)
+ end-delim-pos (match-end 0))
(when (fboundp 'hproperty:but-delete)
- (hproperty:but-delete start))
+ (hproperty:but-delete start-delim-pos))
+ (goto-char (- (point) (length ebut:end)))
(skip-chars-backward " \t\n\r")
- (skip-chars-backward "0-9")
- (when (eq (preceding-char) (string-to-char ebut:instance-sep))
- (setq start (1- (point))))
+ (setq text-end (point))
+ ;; Limit instance number removal to single digit 2-9
+ ;; in case button text contains a colon-separated
+ ;; number that is part of the text and should not
+ ;; be removed.
+ (skip-chars-backward "2-9")
+ (skip-chars-backward ebut:instance-sep)
+ (when (looking-at (concat (regexp-quote ebut:instance-sep)
+ "[2-9]"
+ (regexp-quote ebut:end)))
+ (setq text-end (point)))
(when (search-backward ebut:start (- (point) (hbut:max-len))
t)
(if current-prefix-arg
- ;; Remove button label, delimiters and preceding
- ;; space, if any.
+ ;; Remove button text, delimiters and preceding space,
if any.
(delete-region (max (point-min)
(1- (match-beginning 0)))
- end)
+ end-delim-pos)
;;
;; Remove button delimiters only.
;;
;; Remove button ending delimiter
- (delete-region start end)
+ (delete-region text-end end-delim-pos)
;; Remove button starting delimiter
(delete-region (match-beginning 0) (match-end 0))))))))
(if (called-interactively-p 'interactive)
(save-excursion
(when (search-forward ebut:end nil t) (funcall form)))
;; Non-interactive invocation.
- (let ((cur-p))
+ (let (cur-flag)
(if (and (or (null key-src) (eq key-src buffer-file-name))
(or (null directory) (eq directory default-directory)))
- (setq cur-p t)
+ (setq cur-flag t)
(set-buffer (find-file-noselect (expand-file-name key-src
directory))))
+ (unless (stringp but-key)
+ (setq but-key (hbut:label-p))
+ (unless (stringp but-key)
+ (hypb:error "(ebut-unmark): No Hyperbole button at point to
unmark")))
(save-excursion
(goto-char (point-min))
(when (re-search-forward (ebut:label-regexp but-key) nil t)
(funcall form)
- ;; If modified a buffer other than the current one,
- ;; save it.
- (or cur-p (save-buffer))))))))
+ ;; If modified a buffer other than the current one, save it.
+ (when cur-flag
+ (save-buffer))))))))
(defun hui:file-find (file-name)
"If FILE-NAME is readable, find it, else signal an error."
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index 16b5ceb..90e072c 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -83,8 +83,7 @@ It provides the following keys:
;;
;; Prevent insertion of characters outside of editable bounds,
;; e.g. after the mouse sets point to a non-editable position
- ;; !! TODO: This was causing kotl-mode:demote-tree (and promote) to fail
- ;; (add-hook 'pre-command-hook #'kotl-mode:pre-self-insert-command)
+ (add-hook 'pre-command-hook #'kotl-mode:pre-self-insert-command)
;;
;; Ensure that outline structure data is saved when save-buffer is called
;; from save-some-buffers, {C-x s}.
@@ -2911,23 +2910,26 @@ newlines at end of tree."
"If within a Koutline, prior to inserting a character, ensure point is in an
editable position.
Mouse may have moved point outside of an editable area. kotl-mode adds
this function to `pre-command-hook'."
- (when (and (eq this-command 'self-insert-command)
- (called-interactively-p 'interactive)
+ (when (and (memq this-command '(self-insert-command
orgtbl-self-insert-command))
(eq major-mode 'kotl-mode)
(not (kview:valid-position-p))
;; Prevent repeatedly moving point to valid position when moving
trees
(not (hyperb:stack-frame '(kcell-view:to-label-end))))
- (let ((start (kcell-view:start))
- (end (kcell-view:end-contents)))
- (cond ((and (<= start (point)) (<= (point) end))
- ;; in-between paragraph breaks within a single cell
- (move-to-column (kcell-view:indent nil label-sep-len)))
- ((< (- (point) (or (kview:label-separator-length kview) 1))
- (kcell-view:to-visible-label-end))
- ;; Skip past cell label
- (goto-char (kcell-view:start)))
- ;; Move to cell end
- (t (goto-char (kcell-view:end-contents)))))))
+ (when (not (kview:valid-position-p))
+ (kotl-mode:to-valid-position))
+ ;; !! TODO: Delete this commented code if no other issues found.
+ ;; (let ((start (kcell-view:start))
+ ;; (end (kcell-view:end-contents)))
+ ;; (cond ((and (<= start (point)) (<= (point) end))
+ ;; ;; in-between paragraph breaks within a single cell
+ ;; (move-to-column (kcell-view:indent nil label-sep-len)))
+ ;; ((< (- (point) (or (kview:label-separator-length kview) 1))
+ ;; (kcell-view:to-visible-label-end))
+ ;; ;; Skip past cell label
+ ;; (goto-char (kcell-view:start)))
+ ;; ;; Move to cell end
+ ;; (t (goto-char (kcell-view:end-contents)))))
+ ))
(defun kotl-mode:print-attributes (kview)
"Print to the `standard-output' stream the attributes of the current visible
kcell.
diff --git a/kotl/kview.el b/kotl/kview.el
index d346ea2..b919418 100644
--- a/kotl/kview.el
+++ b/kotl/kview.el
@@ -1212,6 +1212,8 @@ unless no next cell."
"Move to the point holding the kcell property within the previous cell of
the current kview.
With optional VISIBLE-P, consider only visible cells. Return t
unless no previous cell."
+ (when (not (kview:valid-position-p))
+ (kotl-mode:to-valid-position t))
(let* ((opoint (point))
(pos opoint))
(when (kview:valid-position-p)
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index f9bbd36..d495194 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7585,9 +7585,9 @@ bindings that hide global Hyperbole keys.
@cindex minibuffer menu bindings
@findex hyperbole-set-key
Use @bkbd{M-x hyperbole-set-key @key{RET}} to bind any global key to
-any Hyperbole minibuffer item. This command will first prompt for the
+any Hyperbole minibuffer menu item. This command will first prompt for the
key sequence you want to use to activate the menu item. Immediately
-after it will display the Hyperbole top-level minibuffer menu. Simply
+after, it will display the Hyperbole top-level minibuffer menu. Simply
select the item you want to bind to your key.
@node Default Hyperbole Bindings, , Binding Minibuffer Menu Items, Hyperbole
Key Bindings
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/hyperbole 7ef5033: kotl-mode and button creations fixes,
ELPA Syncer <=