emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 1a0f750 6/8: Improve Action Key completion se


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 1a0f750 6/8: Improve Action Key completion selection and add additional tests
Date: Sat, 10 Apr 2021 18:13:13 -0400 (EDT)

branch: externals/hyperbole
commit 1a0f7507a3b01293953f57f98d0edc34ad4191a1
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Improve Action Key completion selection and add additional tests
---
 Changes                | 20 +++++++++++++++++++-
 HY-TALK/HY-TALK.org    | 42 +++++++++++++++++++++++++-----------------
 HY-TALK/HYPB           | 22 ++++++++++++----------
 Makefile               |  2 +-
 hargs.el               | 10 +++++++---
 hibtypes.el            |  6 ++++++
 hmouse-sh.el           |  9 ++++++---
 hui-window.el          | 31 ++++++++++++++++++-------------
 hypb-ert.el            |  1 +
 hypb-maintenance.el    |  4 ++--
 hypb.el                | 25 ++++++++++++++++++++++++-
 hyperbole.el           | 21 +++++++++++----------
 test/demo-tests.el     |  6 ++++++
 test/hibtypes-tests.el |  6 ++++++
 14 files changed, 144 insertions(+), 61 deletions(-)

diff --git a/Changes b/Changes
index 50c247a..16fc419 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,9 @@
+2021-04-05  Bob Weiner  <rsw@gnu.org>
+
+* Makefile (ELC_COMPILE): Fix hib-org.elc (was .el).
+
+* hibtypes.el (hypb-ert): Load Hyperbole test runner ibtypes.
+
 2021-04-04  Mats Lidell  <matsl@gnu.org>
 
 * HY-NEWS: Section about hypb-ert
@@ -18,13 +24,25 @@
 * hui-mouse.el (hkey-alist, smart-todotxt, smart-todotxt-assist): Add
     support for todotxt-mode
 
+2021-03-26  Bob Weiner  <rsw@gnu.org>
+
+* hypb.el (hypb:get-completion): Extract from part of `choose-completion' from 
"simple.el".
+  hargs.el (hargs:completion): Utilize hypb:get-completion to match with 
current Emacs.
+
+* hui-window.el (hmouse-emacs-modeline-event-p):
+                (hmouse-inactive-minibuffer-p):
+                (hmouse-x-coord):
+                (hmouse-y-coord):
+  hmouse-sh.el (hmouse-move-point-emacs): Add window-valid-p check ahead of 
window-minibuffer-p
+    to prevent errors if clicked within a transient window like which-key.
+
 2021-03-21  Mats Lidell  <matsl@gnu.org>
 
 * test/hbut-tests.el (hbut-defal-url-%s): Add test for %s format-style.
 
 2021-03-21  Bob Weiner  <rsw@gnu.org>
 
-* hbut.el (defal): Added support for use of %s format-style grouping 1 arg
+* hbut.el (defal): Add support for use of %s format-style grouping 1 arg
     substitution.
   man/hyperbole.texi (Action Button Link Types): Documented.
   DEMO (defal): Added new example of Google file type search button.
diff --git a/HY-TALK/HY-TALK.org b/HY-TALK/HY-TALK.org
index a9add8d..897c6ad 100644
--- a/HY-TALK/HY-TALK.org
+++ b/HY-TALK/HY-TALK.org
@@ -82,6 +82,7 @@
 
 * Hyperbole - What Is It
 
+  
|---------------------+----------------------------------------------------------|
   | Hyperbole Component | Description                                          
    |
   
|---------------------+----------------------------------------------------------|
   | Action/Assist Keys  | 2 global keys for hypertext everywhere in Emacs      
    |
@@ -100,7 +101,7 @@
   | HyControl           | Fast control of your windows and frames              
    |
   |                     |                                                      
    |
   | HyRolo              | Fast retrieval of hyperlinked records in * outline 
files |
-
+  
|---------------------+----------------------------------------------------------|
 
 
 * Setup and Use
@@ -222,22 +223,25 @@ A Few Common Examples:
 
 * Many More to Learn Across Time
 
-                       Implicit Button Types
-
-| action            | annot-bib              | completion               |
-| cscope            | ctags                  | debbugs-gnu-mode         |
-| debbugs-gnu-query | debugger-source        | dir-summary              |
-| doc-id            | elink                  | elisp-compiler-msg       |
-| etags             | function-in-buffer     | git-commit-reference     |
-| glink             | gnus-push-button       | grep-msg                 |
-| hyp-address       | hyp-source             | id-cflow                 |
-| ilink             | Info-node              | ipython-stack-frame      |
-| kbd-key           | klink                  | mail-address             |
-| man-apropos       | markdown-internal-link | org-mode                 |
-| patch-msg         | pathname               | pathname-line-and-column |
-| rfc               | rfc-toc                | ripgrep-msg              |
-| social-reference  | texinfo-ref            | text-toc                 |
-| www-url           |                        |                          |
+|-----------------------+------------------------+--------------------------|
+|                          Implicit Button Types                            |
+|-----------------------+------------------------+--------------------------|
+| action                | annot-bib              | completion               |
+| cscope                | ctags                  | debbugs-gnu-mode         |
+| debbugs-gnu-query     | debugger-source        | dir-summary              |
+| doc-id                | elink                  | elisp-compiler-msg       |
+| etags                 | function-in-buffer     | git-commit-reference     |
+| glink                 | gnus-push-button       | grep-msg                 |
+| hyp-address           | hyp-source             | id-cflow                 |
+| ilink                 | Info-node              | ipython-stack-frame      |
+| kbd-key               | klink                  | mail-address             |
+| man-apropos           | markdown-internal-link | org-mode                 |
+| patch-msg             | pathname               | pathname-line-and-column |
+| rfc                   | rfc-toc                | ripgrep-msg              |
+| social-reference      | texinfo-ref            | text-toc                 |
+| www-url               |                        |                          |
+|---------------------------------------------------------------------------|
+
 
 Stored in their own namespace, 'ibtypes::', so to see the doc on the
 'pathname' ibtype, use {C-h f ibtypes::pathname RET}.
@@ -256,6 +260,9 @@ Stored in their own namespace, 'ibtypes::', so to see the 
doc on the
 
 *                            Action Types
 
+|-----------------------------------------------------------------------------|
+|                            Action Types                                     |
+|-----------------------------------------------------------------------------|
 | annot-bib               | completion                   | www-url            |
 | debbugs-gnu-query       | display-boolean              | display-variable   |
 | eval-elisp              | exec-kbd-macro               | exec-shell-cmd     |
@@ -270,6 +277,7 @@ Stored in their own namespace, 'ibtypes::', so to see the 
doc on the
 | link-to-string-match    | link-to-texinfo-node         | link-to-web-search |
 | man-show                | org-internal-link-target     | org-link           |
 | org-radio-target        | rfc-toc                      | text-toc           |
+|-----------------------------------------------------------------------------|
 
 Stored in their own namespace, 'actypes::', so to see the doc on the
 'org-link' actype, use {C-h f actypes::org-link RET}.
diff --git a/HY-TALK/HYPB b/HY-TALK/HYPB
index 1a4866c..8c39569 100644
--- a/HY-TALK/HYPB
+++ b/HY-TALK/HYPB
@@ -12,16 +12,18 @@ or interactively after loading Hyperbole:
 
 ** Keypression - overlaying parts of buffer (shows trail of keys)
 
-  <keypression-mode 1>
-  <keypression-mode 0>
-
-<setq keypression-use-child-frame nil
-      keypression-fade-out-delay 3.0
-      keypression-frame-justify 'keypression-left-justified
-      keypression-cast-command-name t
-      keypression-cast-command-name-format "%s  %s"
-      keypression-combine-same-keystrokes t
-      keypression-font-face-attribute '(:width normal :height 200 :weight 
bold)>
+  Install:    <package-install 'keypression>
+  Activate:   <keypression-mode 1>
+  Deactivate: <keypression-mode 0>
+
+  Configure:
+    <setq keypression-use-child-frame nil
+         keypression-fade-out-delay 3.0
+         keypression-frame-justify 'keypression-left-justified
+         keypression-cast-command-name t
+         keypression-cast-command-name-format "%s  %s"
+         keypression-combine-same-keystrokes t
+         keypression-font-face-attribute '(:width normal :height 200 :weight 
bold)>
 
 
 * Pathname Prefixes
diff --git a/Makefile b/Makefile
index cef80dc..e427a90 100644
--- a/Makefile
+++ b/Makefile
@@ -167,7 +167,7 @@ EL_KOTL = kotl/kexport.el kotl/kfile.el kotl/kfill.el 
kotl/kimport.el kotl/klabe
          kotl/kview.el kotl/kvspec.el
 
 ELC_COMPILE =  hactypes.elc hibtypes.elc hib-debbugs.elc hib-doc-id.elc 
hib-kbd.elc \
-            hib-org.el hib-social.elc hact.elc \
+            hib-org.elc hib-social.elc hact.elc \
             hargs.elc hbdata.elc hbmap.elc hbut.elc hgnus.elc hhist.elc \
             hinit.elc hload-path.elc hmail.elc hmh.elc hmoccur.elc 
hmouse-info.elc \
             hmouse-drv.elc hmouse-key.elc hmouse-mod.elc hmouse-sh.elc 
hmouse-tag.elc \
diff --git a/hargs.el b/hargs.el
index cb18fc1..b21fe54 100644
--- a/hargs.el
+++ b/hargs.el
@@ -416,7 +416,10 @@ Also insert unless optional NO-INSERT is non-nil.
 Insert in minibuffer if active or in other window if minibuffer is inactive."
   (interactive '(nil))
   (when (or (string-match "[* ]Completions\\*\\'" (buffer-name))
-           (eq major-mode 'completion-mode))
+           (eq major-mode 'completion-mode)
+           (and (boundp 'which-key--buffer)
+                (eq (window-buffer action-key-depress-window) 
which-key--buffer)
+                (eq (window-buffer action-key-release-window) 
which-key--buffer)))
     (let ((opoint (point))
          (owind (selected-window)))
       (when (re-search-backward "^\\|\t\\| [ \t]" nil t)
@@ -462,8 +465,9 @@ Insert in minibuffer if active or in other window if 
minibuffer is inactive."
                               (1+ (match-beginning 0)))
                              entry))))
                (or no-insert
-                   (if entry (progn (erase-buffer)
-                                    (insert entry)))))
+                   (when entry
+                     (erase-buffer)
+                     (insert entry))))
               ;; In buffer, non-minibuffer completion.
               ;; Only insert entry if last buffer line does
               ;; not end in entry.
diff --git a/hibtypes.el b/hibtypes.el
index 2a478e7..d4b87f9 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -83,6 +83,12 @@
 ;; ibtype priorities.
 
 ;;; ========================================================================
+;;; Runs Hyperbole tests
+;;; ========================================================================
+
+(load "hypb-ert")
+
+;;; ========================================================================
 ;;; Follows Org mode links and radio targets and cycles Org heading views
 ;;; ========================================================================
 
diff --git a/hmouse-sh.el b/hmouse-sh.el
index 784d011..7ee0c48 100644
--- a/hmouse-sh.el
+++ b/hmouse-sh.el
@@ -424,7 +424,8 @@ point determined by 
`mouse-select-region-move-to-beginning'."
       (with-selected-frame start-w-or-f (setq start-w-or-f (selected-window))))
     (when (framep end-w-or-f)
       (with-selected-frame end-w-or-f (setq end-w-or-f (selected-window))))
-    (if (and (window-minibuffer-p start-w-or-f)
+    (if (and (window-valid-p start-w-or-f)
+            (window-minibuffer-p start-w-or-f)
             (not (minibuffer-window-active-p start-w-or-f)))
        ;; Select the ending frame only, not the window pressed within.
        (select-frame (window-frame end-w-or-f))
@@ -438,13 +439,15 @@ point determined by 
`mouse-select-region-move-to-beginning'."
                     (exchange-point-and-mark))))
        ;; Use event-end in case called from mouse-drag-region.
        ;; If EVENT is a click, event-end and event-start give same value.
-       (if (and (window-minibuffer-p end-w-or-f)
+       (if (and (window-valid-p end-w-or-f)
+                (window-minibuffer-p end-w-or-f)
                 (not (minibuffer-window-active-p end-w-or-f)))
            ;; Select the ending frame only, not the window pressed within.
            (select-frame (window-frame end-w-or-f))
          (condition-case ()
              (hmouse-posn-set-point (event-end event))
-           (error (select-frame (window-frame end-w-or-f)))))))))
+           (error (when (window-valid-p end-w-or-f)
+                    (select-frame (window-frame end-w-or-f))))))))))
 
 (defun hmouse-move-point-eterm (arg-list)
   (apply 'mouse-move-point arg-list))
diff --git a/hui-window.el b/hui-window.el
index 1bc642d..51246b4 100644
--- a/hui-window.el
+++ b/hui-window.el
@@ -728,7 +728,7 @@ Ignores minibuffer window."
         (get-buffer-window (marker-buffer coords)))
        ((eventp coords)
         (let ((w-or-f (posn-window (event-start coords))))
-          (if (framep w-or-f) (setq w-or-f (frame-selected-window w-or-f)))
+          (when (framep w-or-f) (setq w-or-f (frame-selected-window w-or-f)))
           w-or-f))
        (t (let ((window-list (hypb:window-list 'no-minibuf))
                 (window)
@@ -794,8 +794,9 @@ With optional boolean NEW-WINDOW non-nil, sensibly split 
the release window befo
 (defun hmouse-inactive-minibuffer-p ()
   "Return t if the last command event was a mouse press or release within an 
inactive minibuffer, else nil."
   (let ((window (posn-window (event-start last-command-event))))
-    (if (framep window) (setq window (frame-selected-window window)))
-    (and (window-minibuffer-p window)
+    (when (framep window) (setq window (frame-selected-window window)))
+    (and (window-live-p window)
+        (window-minibuffer-p window)
         (not (minibuffer-window-active-p window)))))
 
 (defun hmouse-insert-region ()
@@ -990,8 +991,8 @@ window, its frame may have been moved by a bottommost 
modeline drag."
       ;; the mode-line area, so manually compute if that was the location.
       (let* ((w (smart-window-of-coords event))
             ;; Do all calculations in pixels if possible.
-            (line-height (if w (frame-char-height (window-frame w))))
-            (mode-ln (if w (nth 3 (window-edges w nil t t))))
+            (line-height (when (and w (window-live-p w)) (frame-char-height 
(window-frame w))))
+            (mode-ln (when (and w (window-live-p w)) (nth 3 (window-edges w 
nil t t))))
             (last-press-y (cdr (posn-x-y (event-start event)))))
        (and (not (eq w (minibuffer-window)))
             last-press-y mode-ln (< (- mode-ln last-press-y) line-height)))))
@@ -1232,13 +1233,15 @@ of the Smart Key."
                 (hypb:goto-marker args)
                 (current-column))
             (eval (cdr (assoc (hyperb:window-system)
-                              '(("emacs" . (progn (if (eventp args) (setq args 
(event-start args)))
+                              '(("emacs" . (progn (when (eventp args) (setq 
args (event-start args)))
                                                   (cond
                                                    ((posnp args)
                                                     (let ((w-or-f (posn-window 
args)))
-                                                      (if (framep w-or-f)
-                                                          (setq w-or-f 
(frame-selected-window w-or-f)))
-                                                      (+ (car (posn-col-row 
args))
+                                                      (when (framep w-or-f)
+                                                        (setq w-or-f 
(frame-selected-window w-or-f)))
+                                                      (+ (condition-case ()
+                                                             (car 
(posn-col-row args))
+                                                           (error 0))
                                                          (nth 0 (window-edges 
w-or-f)))))
                                                    (t (car args)))))
                                 ("next"   .  (nth 1 args))
@@ -1248,12 +1251,14 @@ of the Smart Key."
 (defun hmouse-y-coord (args)
   "Return y coordinate in frame lines from window system dependent ARGS or 
nil."
   (let ((y (eval (cdr (assoc (hyperb:window-system)
-                            '(("emacs" . (progn (if (eventp args) (setq args 
(event-start args)))
+                            '(("emacs" . (progn (when (eventp args) (setq args 
(event-start args)))
                                                 (cond ((posnp args)
                                                        (let ((w-or-f 
(posn-window args)))
-                                                         (if (framep w-or-f)
-                                                             (setq w-or-f 
(frame-selected-window w-or-f)))
-                                                         (+ (cdr (posn-col-row 
args))
+                                                         (when (framep w-or-f)
+                                                           (setq w-or-f 
(frame-selected-window w-or-f)))
+                                                         (+ (condition-case ()
+                                                                (cdr 
(posn-col-row args))
+                                                              (error 0))
                                                             (nth 1 
(window-edges w-or-f)))))
                                                       (t (cdr args)))))
                               ("next"   .  (nth 2 args))
diff --git a/hypb-ert.el b/hypb-ert.el
index 623206d..45a37a2 100644
--- a/hypb-ert.el
+++ b/hypb-ert.el
@@ -25,6 +25,7 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'ert))
 (require 'hbut)
 (require 'hargs)
 
diff --git a/hypb-maintenance.el b/hypb-maintenance.el
index 3d5d387..af7a454 100644
--- a/hypb-maintenance.el
+++ b/hypb-maintenance.el
@@ -8,8 +8,8 @@
 ;;; Commentary:
 
 ;;; Code:
-(require 'kexport)
-(require 'kimport)
+(require 'kexport "kotl/kexport")
+(require 'kimport "kotl/kimport")
 
 (defvar hypb:web-repo-location "../hyperbole-web/"
   "The location of hyperbole repo for the web pages.")
diff --git a/hypb.el b/hypb.el
index bd48db5..ee97ecf 100644
--- a/hypb.el
+++ b/hypb.el
@@ -63,7 +63,6 @@ Rest of ARGS are passed as arguments to PROGRAM."
       (kill-buffer buf))
     found))
 
-
 (defun hypb:char-count (char array)
   "Return count of occurrences of CHAR in ARRAY."
   (let ((i 0) (c 0) (l (length array)))
@@ -377,6 +376,30 @@ are replaced.  Returns body of modified FUNC-SYM."
          body))
       body)))
 
+;; Extracted from part of `choose-completion' in "simple.el"
+(defun hypb:get-completion (&optional event)
+  "Return the completion at point.
+If EVENT, use EVENT's position to determine the starting position."
+  (interactive (list last-nonmenu-event))
+  ;; In case this is run via the mouse, give temporary modes such as
+  ;; isearch a chance to turn off.
+  (run-hooks 'mouse-leave-buffer-hook)
+  (with-current-buffer (window-buffer (posn-window (event-start event)))
+    (save-excursion
+      (goto-char (posn-point (event-start event)))
+      (let (beg end)
+        (cond
+         ((and (not (eobp)) (get-text-property (point) 'mouse-face))
+          (setq end (point) beg (1+ (point))))
+         ((and (not (bobp))
+               (get-text-property (1- (point)) 'mouse-face))
+          (setq end (1- (point)) beg (point)))
+         (t (error "No completion here")))
+        (setq beg (previous-single-property-change beg 'mouse-face))
+        (setq end (or (next-single-property-change end 'mouse-face)
+                      (point-max)))
+        (buffer-substring-no-properties beg end)))))
+
 (defun hypb:get-raw-syntax-descriptor (char &optional syntax-table)
   "Return the raw syntax descriptor for CHAR using the current syntax table or 
optional SYNTAX-TABLE."
   (aref (or syntax-table (syntax-table)) char))
diff --git a/hyperbole.el b/hyperbole.el
index d6dc0d7..fa269d4 100644
--- a/hyperbole.el
+++ b/hyperbole.el
@@ -1,12 +1,12 @@
 ;;; hyperbole.el --- GNU Hyperbole: The Everyday Hypertextual Information 
Manager
 
-;; Copyright (C) 1992-2019  Free Software Foundation, Inc.
+;; Copyright (C) 1992-2021  Free Software Foundation, Inc.
 
 ;; Author:           Bob Weiner
 ;; Maintainer:       Bob Weiner <rsw@gnu.org>, Mats Lidell <matsl@gnu.org>
 ;; Created:          06-Oct-92 at 11:52:51
 ;; Released:         21-Mar-21
-;; Version:          7.1.4 (pre-release)
+;; Version:          7.1.4pre
 ;; Keywords:         comm, convenience, files, frames, hypermedia, languages, 
mail, matching, mouse, multimedia, outlines, tools, wp
 ;; Package:          hyperbole
 ;; Package-Requires: ((emacs "24.4"))
@@ -637,13 +637,13 @@ If FLAG is nil then text is shown, while if FLAG is t the 
text is hidden."
   ;;
   (run-hooks 'hyperbole-init-hook)
   (hyperb:check-dir-user)
-  (or (stringp hyperb:user-email)
-      (setq hyperb:user-email
-           (or (and (boundp 'user-mail-address)
-                    (stringp user-mail-address)
-                    (string-match "@" user-mail-address)
-                    user-mail-address)
-               (concat (user-login-name) (hypb:domain-name)))))
+  (unless (stringp hyperb:user-email)
+    (setq hyperb:user-email
+         (or (and (boundp 'user-mail-address)
+                  (stringp user-mail-address)
+                  (string-match "@" user-mail-address)
+                  user-mail-address)
+             (concat (user-login-name) (hypb:domain-name)))))
   ;;
   ;; When running from git source and not a release package, ensure
   ;; auto-autoload.el files are already generated or generate them.
@@ -680,7 +680,8 @@ If FLAG is nil then text is shown, while if FLAG is t the 
text is hidden."
   ;; removal of further local bindings.
   (if (featurep 'hyperbole)
       (hkey-install-override-local-bindings)
-    (add-hook 'after-load-alist '(hyperbole 
hkey-install-override-local-bindings)))
+    (eval-after-load 'hyperbole
+      '(hkey-install-override-local-bindings)))
   ;;
   ;; Hyperbole initialization is complete.
   (message "Initializing Hyperbole...done")
diff --git a/test/demo-tests.el b/test/demo-tests.el
index a0cc222..d552de3 100644
--- a/test/demo-tests.el
+++ b/test/demo-tests.el
@@ -378,5 +378,11 @@
         (hy-test-helpers:should-last-message "Factorial of 5 = 120"))
     (kill-buffer "DEMO")))
 
+;; This file can't be byte-compiled without the `el-mock' package (because of
+;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.
+;;  Local Variables:
+;;  no-byte-compile: t
+;;  End:
+
 (provide 'demo-tests)
 ;;; demo-tests.el ends here
diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el
index 4f74482..4be61b5 100644
--- a/test/hibtypes-tests.el
+++ b/test/hibtypes-tests.el
@@ -241,5 +241,11 @@
 
 ;; completion
 
+;; This file can't be byte-compiled without the `el-mock' package (because of
+;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.
+;;  Local Variables:
+;;  no-byte-compile: t
+;;  End:
+
 (provide 'hibtypes-tests)
 ;;; hibtypes-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]