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

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

[elpa] externals/hyperbole 152e2be 47/53: Highlighted explicit buttons w


From: Robert Weiner
Subject: [elpa] externals/hyperbole 152e2be 47/53: Highlighted explicit buttons when yanked; fixed region location bugs with hmouse-drag-thing and region kill, copy and yank
Date: Wed, 15 Nov 2017 22:47:09 -0500 (EST)

branch: externals/hyperbole
commit 152e2be48e5bbd8da20193a28ff88f4e62fe80df
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>

    Highlighted explicit buttons when yanked; fixed region location bugs with 
hmouse-drag-thing and region kill, copy and yank
    
    2017-11-13  Bob Weiner  <address@hidden>
    
    * hui-window.el (hmouse-drag-thing): Added error if drag ends within the 
delimited thing region, so user knows
        that this is an invalid drag.
                    (hmouse-yank-region, hmouse-kill-and-yank-region): Made 
no-op unless hkey-region is non-nil.
        This handles the hmouse-drag-thing case when we want that predicate 
true (so no other predicate matches)
        but there is no region to copy or kill, e.g. when the release point is 
within the thing itself.
    
    * hui-select.el (hui-select-delimited-thing): Fixed to match doc and work 
as a predicate.
    
    * hui-window.el (hmouse-goto-depress-prev-point): Deleted since it 
duplicated hmouse-goto-region-prev-point.
                    (hmouse-goto-region-prev-point): Added missing check for 
prev-point nil when setting loc.
        This caused the Smart Keys to fail when used if a Lisp backtrace was 
active.
                    (hmouse-drag-thing): Erased any saved location of a region 
prior to Smart Key depress since
        now we have a new region location.  This prevents 
hmouse-kill-and-yank-region from jumping to the old
        location.  Also fixed edge cases where want to copy or move thing to 
the beginning or end of the thing region.
                    (hmouse-goto-region-point): Renamed to 
hmouse-goto-region-prev-point, for clarity.
                    (hmouse-kill-and-yank-region, hmouse-kill-region): Used 
value of point saved in hkey-value to determine
        the region if non-nil.
    
    * hui-select.el (hui-select-delimited-thing, hui-select-thing): Changed to 
use use-region-p.
      hmouse-drv.el (hmouse-use-region-p): Added and used to improve 
hmouse-drag-thing.
                    (hmouse-save-region): Simplified.
      hui-window.el (hmouse-drag-region-active): Changed call of 
region-active-p to hmouse-use-region-p.
    
    * hui-window.el (hmouse-kill-and-yank-region): Fixed error that was testing 
not in depress buffer (as desired) but the
        buffer prior to depress.  Also protected insertion from syntax-directed 
indentation errors.
    
    * hui-em-but.el
      hui-xe-but.el (hproperty:but-create-on-yank): Added as handler for 
yank-handled-properties so explicit buttons are
        re-highlighted when yanked after being killed.
---
 .hypb         | Bin 4571 -> 4188 bytes
 Changes       |  33 ++++++
 HY-NEWS       | 108 ++++++++++---------
 MANIFEST      |   2 +-
 hmouse-drv.el |  31 +++---
 hui-em-but.el |   9 +-
 hui-select.el |  45 ++++----
 hui-window.el | 329 ++++++++++++++++++++++++++++++----------------------------
 hui-xe-but.el |   7 ++
 9 files changed, 315 insertions(+), 249 deletions(-)

diff --git a/.hypb b/.hypb
index 007fe94..65fd41d 100644
Binary files a/.hypb and b/.hypb differ
diff --git a/Changes b/Changes
index 1974d8e..d998759 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,36 @@
+2017-11-13  Bob Weiner  <address@hidden>
+
+* hui-window.el (hmouse-drag-thing): Added error if drag ends within the 
delimited thing region, so user knows
+    that this is an invalid drag.
+                (hmouse-yank-region, hmouse-kill-and-yank-region): Made no-op 
unless hkey-region is non-nil.
+    This handles the hmouse-drag-thing case when we want that predicate true 
(so no other predicate matches)
+    but there is no region to copy or kill, e.g. when the release point is 
within the thing itself.
+
+* hui-select.el (hui-select-delimited-thing): Fixed to match doc and work as a 
predicate.
+
+* hui-window.el (hmouse-goto-depress-prev-point): Deleted since it duplicated 
hmouse-goto-region-prev-point.
+                (hmouse-goto-region-prev-point): Added missing check for 
prev-point nil when setting loc.
+    This caused the Smart Keys to fail when used if a Lisp backtrace was 
active.
+                (hmouse-drag-thing): Erased any saved location of a region 
prior to Smart Key depress since
+    now we have a new region location.  This prevents 
hmouse-kill-and-yank-region from jumping to the old
+    location.  Also fixed edge cases where want to copy or move thing to the 
beginning or end of the thing region.
+                (hmouse-goto-region-point): Renamed to 
hmouse-goto-region-prev-point, for clarity.
+                (hmouse-kill-and-yank-region, hmouse-kill-region): Used value 
of point saved in hkey-value to determine
+    the region if non-nil. 
+
+* hui-select.el (hui-select-delimited-thing, hui-select-thing): Changed to use 
use-region-p.
+  hmouse-drv.el (hmouse-use-region-p): Added and used to improve 
hmouse-drag-thing.
+                (hmouse-save-region): Simplified.
+  hui-window.el (hmouse-drag-region-active): Changed call of region-active-p 
to hmouse-use-region-p.
+
+
+* hui-window.el (hmouse-kill-and-yank-region): Fixed error that was testing 
not in depress buffer (as desired) but the
+    buffer prior to depress.  Also protected insertion from syntax-directed 
indentation errors.
+
+* hui-em-but.el
+  hui-xe-but.el (hproperty:but-create-on-yank): Added as handler for 
yank-handled-properties so explicit buttons are
+    re-highlighted when yanked after being killed.
+
 2017-11-06  Bob Weiner  <address@hidden>
 
 * hyrolo-demo.el (hyrolo-demo-quit): Added to unload hyrolo-demo code and used 
in demo.
diff --git a/HY-NEWS b/HY-NEWS
index b27c099..1524f30 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -15,7 +15,7 @@
       actions allow for rapid display of buffers, windows and frames wherever
       you like.
 
-      Major features include:
+      Major new features include:
 
         * Dragging items from Dired or the Buffer Menu for display in existing
           or new windows and frames.  Action Key drag from the first line (or
@@ -67,6 +67,9 @@
       a pathname is maintained as is any prior in-file location when prompting
       for changes.
 
+    - Yanking Explicit Buttons: When copying or moving explicit buttons, they
+      are now re-highlighted when yanked into a new position.
+
     - EWW Support: Added Action and Assist Key support for browsing links in
       eww (the Emacs web browser) and for activating history links in the eww
       history buffer.
@@ -133,16 +136,16 @@
       an external viewer.
 
     - Emacs Push-buttons: An Assist Key press on an Emacs push-button 
previously
-      displayed its keyboard-action help string but not its mouse-action help 
string.
-      Now it displays the mouse-action when appropriate.
+      displayed its keyboard-action help string but not its mouse-action help
+      string.  Now it displays the mouse-action when appropriate.
 
     - Texinfo References: An Action Key press on an Emacs Lisp @findex
       (function) or @vindex (variable) entry displays the documentation for
       that entry.
 
-    - Debbugs Issues: Eliminated match of #id-number as a bug reference; 'bug' 
or
-      similar prefix is now required so there is no ambiguity with social 
references
-      including 'git #commit-number'.
+    - Debbugs Issues: Eliminated match of #id-number as a bug reference; 'bug'
+      or similar prefix is now required so there is no ambiguity with social
+      references including 'git #commit-number'.
 
   CUSTOMIZATON
 
@@ -153,14 +156,14 @@
   DOCUMENTATION
 
     - Hyperbole HTML Manual: The HTML version of the Hyperbole Manual now uses
-      a css stylesheet similar to that used for the Hyperbole Home page, making
+      css stylesheet similar to that used for the Hyperbole Home page, making
       it look much better and easier to navigate.
 
     - Drags: Updated Hyperbole Manual with all new Smart Mouse Key drag 
actions.
 
     - Smart Key Help: Improved help documentation for Smart Keys when they
-      contain multiple clauses connected with 'or' logic, e.g. do 'a' or 'b' or
-      'c'.
+      contain multiple clauses connected with 'or' logic, e.g. do 'a' or 'b'
+      or 'c'.
 
     - New Hyperbole Manual Sections:
         * Referent Display - setting of where link referents are displayed
@@ -170,12 +173,13 @@
        * Future Work - Direct Manipulation
 
     - Git References: In the Implicit Buttons section of the Hyperbole Manual,
-      added documentation for git-reference, git-commit-reference and 
github-reference.
+      added documentation for git-reference, git-commit-reference and
+      github-reference.
 
-    - Toggle Key Bindings: In the Smart Key Bindings section of the Hyperbole 
Manual,
-      explained hyperbole-toggle-bindings (toggles keyboard and mouse keys) 
rather
-      than hmouse-toggle-bindings (toggles only mouse keys).  Moved the latter 
to
-      the Global Key Bindings appendix.
+    - Toggle Key Bindings: In the Smart Key Bindings section of the Hyperbole
+      Manual, explained hyperbole-toggle-bindings (toggles keyboard and mouse
+      keys) rather than hmouse-toggle-bindings (toggles only mouse keys).
+      Moved the latter to the Global Key Bindings appendix.
 
     - Other Hyperbole Manual Section Changes:
         * Button Colors: Added doc on hproperty:but-highlight-flag.
@@ -199,14 +203,14 @@
 
     - HyControl Minor Modes: HyControl is now two minor modes, one for frames
       and one for windows.  It uses standard key bindings and standard Emacs
-      event processing instead of its own event loop, so any keys not bound
-      in a HyControl mode now work normally.  HyControl Windows Mode displays
+      event processing instead of its own event loop, so any keys not bound in
+      a HyControl mode now work normally.  HyControl Windows Mode displays
       HyWin in the modeline and HyControl Frames Mode displays HyFrm while
       active.  Both modes invert the modeline colors so you don't forget you
       are in a special mode.
 
-    - address@hidden is an incredible new key binding and command that creates 
a grid
-      of windows within a frame by splitting the frame into a number of equally
+    - address@hidden is an incredible new key binding and command that creates 
a grid of
+      windows within a frame by splitting the frame into a number of equally
       sized windows specified by a number of rows and columns (typically as
       prefix arg digits).  Each window shows a different buffer, if possible,
       with a prefix arg of 0 prompting for a major mode and first displaying
@@ -225,8 +229,8 @@
 
       {M-x hycontrol-windows-grid-repeatedly RET} allows rapid visual testing
       of different grid layouts or filters as it prompts you for a grid size,
-      displays it and then prompts you again until your press RET without 
giving
-      a size.
+      displays it and then prompts you again until your press RET without
+      giving a size.
 
       See "Demo#Windows Grid" for example use.
 
@@ -241,48 +245,50 @@
       {F} moves a window to a new frame and deletes the the source window
 
     - {i}, {j}, {k}, {m} first expand the selected frame to an edge based on
-      their respective positions on a U.S. keyboard, e.g. {i} expands the frame
-      to the top edge; with further invocations, they keep the frame at that 
edge
-      but cut its perpendicular dimension in half (or to any percentage 
specified
-      as an argument), leaving the particular edge fixed.  This allows both 
rapid
-      expansion and contraction of frames with just 4 keys whenever needed.
+      their respective positions on a U.S. keyboard, e.g. {i} expands the
+      frame to the top edge; with further invocations, they keep the frame at
+      that edge but cut its perpendicular dimension in half (or to any
+      percentage specified as an argument), leaving the particular edge fixed.
+      This allows both rapid expansion and contraction of frames with just 4
+      keys whenever needed.
 
       It is easiest to understand by simply trying the keys. See "Demo#Frame
       Commands" for example use.
 
-    - {c} for frame edge location cycling now is available in HyControl Windows
-      mode.
+    - {c} for frame edge location cycling now is available in HyControl
+      Windows mode.
 
     - {p <num>} displays a virtual numeric keypad and moves the selected frame
       to the screen edge position based on the numeric keypad layout, e.g. 3
       moves it to the southeast corner of the screen.  This is for keyboards
-      that do not have a physical numeric keypad.  Before a number is selected,
-      {C-g} or {q} will exit and return to the top-level of the active
-      HyControl mode.
+      that do not have a physical numeric keypad.  Before a number is
+      selected, {C-g} or {q} will exit and return to the top-level of the
+      active HyControl mode.
 
     - {-} in HyControl Windows mode minimizes a window size while trying to
-      display its entire buffer.  Now it will resize the window to 1 line
-      if it cannot display all lines or if all lines are already displayed.
+      display its entire buffer.  Now it will resize the window to 1 line if
+      it cannot display all lines or if all lines are already displayed.
 
     - Minibuffer Help: Improved help strings shown in the minibuffer while
-      HyControl is active.  Added {?} key which toggles this display on and 
off.
+      HyControl is active.  Added {?} key which toggles this display on and
+      off.
       
     - ESC: Removed this as a quit key since now that regular key sequences are
       supported, this is often used as a meta key prefix.  Use {q} to quit.
 
-    - Minibuffer Prompts: Automatically quit from any HyControl mode whenever a
-      minibuffer prompt becomes active so that arguments may be typed normally.
-      Examples include use of {M-:} for Lisp expression evaluation and M-x for
-      entering commands by name.
+    - Minibuffer Prompts: Automatically quit from any HyControl mode whenever
+      a minibuffer prompt becomes active so that arguments may be typed
+      normally.  Examples include use of {M-:} for Lisp expression evaluation
+      and M-x for entering commands by name.
 
   HYROLO
 
     - Google Contacts: New support for searching your Google Contacts with the
       HyRolo Contact Manager; for advanced users only.  Requires use of the
-      Emacs google-contacts package and the non-Emacs gpg public key package to
-      support Google services authorization.  Once configured, these contacts
-      are automatically searched together with local HyRolo files any time a
-      contact search is performed.  See the Google Contacts part in
+      Emacs google-contacts package and the non-Emacs gpg public key package
+      to support Google services authorization.  Once configured, these
+      contacts are automatically searched together with local HyRolo files any
+      time a contact search is performed.  See the Google Contacts part in
       "(hyperbole)HyRolo Settings".
 
     - Dynamic HyRolo List: The HyRolo list of files to search is now computed
@@ -294,9 +300,9 @@
 
     - Unshifted Mouse Keys: By default, Hyperbole mouse keys are Shift-Middle
       (Action Key) and Shift-Right (Assist Key).  For frequent mouse users,
-      there is now {M-x hmouse-add-unshifted-smart-keys RET} which additionally
-      makes the Middle mouse key the Action Key and the Right mouse key the
-      Assist Key, replacing their default Emacs functions.  {M-x
+      there is now {M-x hmouse-add-unshifted-smart-keys RET} which
+      additionally makes the Middle mouse key the Action Key and the Right
+      mouse key the Assist Key, replacing their default Emacs functions.  {M-x
       hmouse-toggle-bindings RET} will toggle between the Emacs and Hyperbole
       mouse bindings.
 
@@ -319,17 +325,17 @@
 
   KOUTLINER
 
-    - `e' Viewspec: Removed ellipses viewspec because ellipses can no longer be
-      turned off with modern Emacs outlining.
+    - `e' Viewspec: Removed ellipses viewspec because ellipses can no longer
+      be turned off with modern Emacs outlining.
 
   MENUS
 
-    - Prefix Arguments: Prefix arguments may now be given to any Hyperbole menu
-      command that accepts them.
+    - Prefix Arguments: Prefix arguments may now be given to any Hyperbole
+      menu command that accepts them.
 
-    - Action Doc Strings: If a menu item has no help string but its action is a
-      function with a doc string, then that doc string will be used to display
-      help for the menu item.
+    - Action Doc Strings: If a menu item has no help string but its action is
+      a function with a doc string, then that doc string will be used to
+      display help for the menu item.
 
     - Key Bindings: The pulldown menu, Hyperbole/Options/Change-Key-Bindings
       now displays the current keys bound to each command for easy reference.
diff --git a/MANIFEST b/MANIFEST
index ce6cab1..438bca8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -18,7 +18,7 @@ hyperbole.el        - Loads and initializes GNU Hyperbole
 Changes             - Summary of changes in recent GNU Hyperbole releases
 
 --- DOCUMENTATION ---
-dir                 - GNU Hyperbole Info directory tree entry
+man/dir             - GNU Hyperbole Info directory tree entry
 man/hyperbole.html  - The GNU Hyperbole Manual  (web version)
 man/hyperbole.info  - The GNU Hyperbole Manual  (GNU Info version)
 man/hyperbole.pdf   - The GNU Hyperbole Manual  (printable version)
diff --git a/hmouse-drv.el b/hmouse-drv.el
index 5485c36..902d4fe 100644
--- a/hmouse-drv.el
+++ b/hmouse-drv.el
@@ -794,23 +794,28 @@ compute the actual release location and include that."
        ;; Remove depress coordinates and send only original release 
coordinates.
        (list (car event) (nth 2 event))))))
 
+(defun hmouse-use-region-p ()
+  "Return t if there is a non-empty, highlighted region, else nil."
+  (cond
+   ;; Newer GNU Emacs
+   ((fboundp 'use-region-p)
+    (let ((use-empty-active-region))
+      (use-region-p)))
+   ;; InfoDock and XEmacs
+   ((fboundp 'region-exists-p)
+    (and (fboundp 'region-active-p) (region-active-p) (region-exists-p)))
+   ;; Older GNU Emacs
+   ((boundp 'transient-mark-mode)
+    (and transient-mark-mode mark-active))))
+
 (defun hmouse-save-region (&optional frame)
   "Save to `hkey-region' and return any active region within the current 
buffer.
 Under InfoDock and XEmacs, `zmacs-region' must be t; under GNU Emacs,
 `transient-mark-mode' must be t or the function does nothing."
-  (if (cond
-       ;; Newer GNU Emacs
-       ((fboundp 'use-region-p)
-       (let ((use-empty-active-region))
-         (use-region-p)))
-       ;; InfoDock and XEmacs
-       ((fboundp 'region-exists-p)
-       (and (fboundp 'region-active-p) (region-active-p) (region-exists-p)))
-       ;; Older GNU Emacs
-       ((boundp 'transient-mark-mode)
-       (and transient-mark-mode mark-active)))
-      (setq hkey-region (buffer-substring (region-beginning) (region-end)))
-    (setq hkey-region nil)))
+  (setq hkey-region
+       (when (hmouse-use-region-p)
+         (buffer-substring (region-beginning) (region-end)))))
+
 
 ;; Save any active region to `hkey-region' when the mouse is moved between 
frames or buffers.
 (if (featurep 'xemacs)
diff --git a/hui-em-but.el b/hui-em-but.el
index 572679d..6ccf25c 100644
--- a/hui-em-but.el
+++ b/hui-em-but.el
@@ -127,7 +127,14 @@ highlighted."
     (ebut:map (lambda (lbl start end)
                (hproperty:but-add start end hproperty:but-face))
              start-delim end-delim regexp-match 'include-delims)))
-              
+
+(defun hproperty:but-create-on-yank (prop-value start end)
+  (save-restriction
+    (narrow-to-region start end)
+    (hproperty:but-create-all)))
+
+(add-to-list 'yank-handled-properties '(hproperty:but-face . 
hproperty:but-create-on-yank))
+
 (defun hproperty:but-delete (&optional pos)
   (let ((but (hproperty:but-get pos)))
     (if but (delete-overlay but))))
diff --git a/hui-select.el b/hui-select.el
index 62b5cd3..6abc237 100644
--- a/hui-select.el
+++ b/hui-select.el
@@ -311,7 +311,7 @@ If invoked repeatedly, this selects bigger and bigger 
things.
 If `hui-select-display-type' is non-nil and this is called
 interactively, the type of selection is displayed in the minibuffer."
   (interactive
-   (cond ((and (fboundp 'region-active-p) (region-active-p))
+   (cond ((and (fboundp 'use-region-p) (use-region-p))
          nil)
         ((and (boundp 'transient-mark-mode) transient-mark-mode mark-active)
          nil)
@@ -320,8 +320,9 @@ interactively, the type of selection is displayed in the 
minibuffer."
          (hui-select-reset)
          nil)))
   (let ((region (hui-select-boundaries (point))))
-    (or region (if (eq hui-select-previous 'punctuation)
-                  (setq region (hui-select-word (point)))))
+    (unless region
+      (when (eq hui-select-previous 'punctuation)
+       (setq region (hui-select-word (point)))))
     (when region
       (goto-char (car region))
       (set-mark (cdr region))
@@ -600,22 +601,21 @@ The non-nil value returned is the function to call to 
select that syntactic unit
 (defun hui-select-delimited-thing ()
   "Selects a markup pair, list, array/vector, set, comment or string at point 
and returns t, else nil."
   (interactive)
-  (hui-select-delimited-thing-call #'hui-select-thing)
-  ;; If selected region is followed by only whitespace and then a
-  ;; newline, add the newline to the region.
-  (if (region-active-p)
-      (if (> (mark) (point))
-         (save-excursion
-           (goto-char (mark))
-           (skip-chars-forward " \t")
-           (and (char-after) (= ?\n (char-after))
-                (set-mark (1+ (point)))))
-       (if (looking-at "[ \t]*\n")
-           (goto-char (match-end 0))))))
+  (prog1 (and (hui-select-delimited-thing-call #'hui-select-thing) t)
+    ;; If selected region is followed by only whitespace and then a
+    ;; newline, add the newline to the region.
+    (if (use-region-p)
+       (if (> (mark) (point))
+           (save-excursion
+             (goto-char (mark))
+             (skip-chars-forward " \t")
+             (and (char-after) (= ?\n (char-after))
+                  (set-mark (1+ (point)))))
+         (if (looking-at "[ \t]*\n")
+             (goto-char (match-end 0)))))))
 
 (defun hui-select-at-delimited-sexp-p ()
-  (if (eolp)
-      nil
+  (unless (eolp)
     (let ((syn-before (if (char-before) (char-syntax (char-before)) 0))
          (syn-after  (if (char-after)  (char-syntax (char-after)) 0)))
       (or (and (/= syn-before ?\\) (or (= syn-after ?\() (= syn-after ?\))))
@@ -628,8 +628,9 @@ Return t if marked, nil otherwise.  If any error occurs 
such as
   unbalanced start and end sexp delimiters, ignore it, and return
   nil."
   (interactive)
-  (let ((mark-sexp-func (lambda () (if (region-active-p) (deactivate-mark))
-                           (mark-sexp) t)))
+  (let ((mark-sexp-func (lambda ()
+                         (if (region-active-p) (deactivate-mark))
+                         (mark-sexp) t)))
     (condition-case nil
        (let ((syn-after (char-syntax (char-after)))
              syn-before)
@@ -693,7 +694,7 @@ mail and news reply modes."
 The non-nil value returned is the function to call to select that syntactic 
unit."
   (unless (and (memq major-mode '(emacs-lisp-mode lisp-mode 
lisp-interaction-mode slime-mode cider-mode))
               ;; Ignore quoted identifier sexpressions, like #'function
-              (char-after) (memq (char-after) '(?# ?\'))))
+              (char-after) (memq (char-after) '(?# ?\')))
       (let ((hui-select-char-p)
            (hui-select-whitespace)
            (hui-select-syntax-alist '((?\" . hui-select-string)
@@ -706,14 +707,14 @@ The non-nil value returned is the function to call to 
select that syntactic unit
                                       ;; multi-char comment delimiters
                                       (?\. . hui-select-punctuation))))
        (hui-select-reset)
-       (funcall func)))
+       (funcall func))))
 
 (defun hui-select-region-bigger-p (old-region new-region)
   "Return t if OLD-REGION is smaller than NEW-REGION and NEW-REGION partially 
overlaps OLD-REGION, or if OLD-REGION is uninitialized."
   (if (null (car old-region))
       t
     (and (> (abs (- (cdr new-region) (car new-region)))
-       (abs (- (cdr old-region) (car old-region))))
+           (abs (- (cdr old-region) (car old-region))))
         ;; Ensure the two regions intersect.
         (or (and (<= (min (cdr new-region) (car new-region))
                      (min (cdr old-region) (car old-region)))
diff --git a/hui-window.el b/hui-window.el
index e085b05..627e13c 100644
--- a/hui-window.el
+++ b/hui-window.el
@@ -169,75 +169,74 @@ drag release window.")
 ;;; Add window handling to hmouse-alist dispatch table.
 ;;;
 (if (not (boundp 'hmouse-alist))
-    (error
-      "\"hui-window.el\": `hmouse-alist' must be defined before loading this.")
-  (or (assoc #'(hmouse-drag-thing) hmouse-alist)
-      (setq hmouse-alist
-           (append
-             '(
-               ;; If click in the minibuffer when it is not active (blank),
-               ;; display the Hyperbole minibuffer menu or popup the jump menu.
-               ((hmouse-inactive-minibuffer-p) .
-                ((funcall action-key-minibuffer-function) . 
-                 (funcall assist-key-minibuffer-function)))
-               ((hmouse-drag-thing) .
-                ((hmouse-yank-region) . (hmouse-kill-and-yank-region)))
-               ((hmouse-drag-window-side) .
-                ((hmouse-resize-window-side) . (hmouse-resize-window-side)))
-               ;;
-               ;; Although Hyperbole can distinguish whether
-               ;; inter-window drags are between frames or not,
-               ;; having different behavior for those 2 cases could
-               ;; be confusing, so treat all modeline drags between
-               ;; windows the same and comment out this next clause.
-               ;;   Modeline drag between frames
-               ;;   ((and (hmouse-modeline-depress) 
(hmouse-drag-between-frames)) .
-               ;;    ((hmouse-clone-window-to-frame) . 
(hmouse-move-window-to-frame)))
-               ;;
-               ;; Drag with release on a Modeline
-               ((and (hmouse-modeline-release) (not (hmouse-modeline-click))) .
-                ((or (hmouse-drag-item-to-display t) (hmouse-buffer-to-window 
t)) .
-                 (hmouse-swap-buffers)))
-               ;; Non-vertical Modeline drag between windows
-               ((and (hmouse-modeline-depress) (hmouse-drag-between-windows)
-                     (not (hmouse-drag-vertically-within-emacs))) .
-                ((hmouse-buffer-to-window) . (hmouse-swap-buffers)))
-               ;; Modeline drag that ends outside of Emacs
-               ((and (hmouse-modeline-depress) 
(hmouse-drag-outside-all-windows)) .
-                ((hycontrol-clone-window-to-new-frame) . 
(hycontrol-window-to-new-frame)))
-               ;; Other Modeline click or drag
-               ((hmouse-modeline-depress) .
-                ((action-key-modeline) . (assist-key-modeline)))
-               ((hmouse-drag-between-windows) .
-                ;; Note that `hui:link-directly' uses any active
-                ;; region as the label of the button to create.
-                ((or (hmouse-drag-item-to-display) (hui:link-directly)) . 
(hmouse-swap-buffers)))
-               ((hmouse-drag-region-active) .
-                ((hmouse-drag-not-allowed) . (hmouse-drag-not-allowed)))
-               ((setq hkey-value (hmouse-drag-horizontally)) .
-                ((hmouse-horizontal-action-drag) . 
(hmouse-horizontal-assist-drag)))
-               ((hmouse-drag-vertically) .
-                ((hmouse-vertical-action-drag) . 
(hmouse-vertical-assist-drag)))
-               ((setq hkey-value (hmouse-drag-diagonally)) .
-                ((call-interactively #'hywconfig-ring-save) .
-                 (call-interactively #'hywconfig-yank-pop)))
-               ;; Window drag that ends outside of Emacs
-               ((hmouse-drag-outside-all-windows) .
-                ((or (hmouse-drag-item-to-display)
-                     (hycontrol-clone-window-to-new-frame)) .
-                 (hycontrol-window-to-new-frame)))
-               ;;
-               ;; Now since this is not a drag and if there was an active
-               ;; region prior to when the Action or Assist Key was
-               ;; pressed, then store point at one end of the region into
-               ;; `hkey-value' and the string value of the region
-               ;; into `hkey-region' which is either yanked, or
-               ;; killed and yanked at the current point.
-               ((hmouse-prior-active-region) .
-                ((hmouse-yank-region) . (hmouse-kill-and-yank-region)))
-               ;;
-               )
-             hmouse-alist))))
+    (error "\"hui-window.el\": `hmouse-alist' must be defined before loading 
this.")
+  (unless (assoc #'(hmouse-inactive-minibuffer-p) hmouse-alist)
+    (setq hmouse-alist
+         (append
+          '(
+            ;; If click in the minibuffer when it is not active (blank),
+            ;; display the Hyperbole minibuffer menu or popup the jump menu.
+            ((hmouse-inactive-minibuffer-p) .
+             ((funcall action-key-minibuffer-function) . 
+              (funcall assist-key-minibuffer-function)))
+            ((hmouse-drag-thing) .
+             ((hmouse-yank-region) . (hmouse-kill-and-yank-region)))
+            ((hmouse-drag-window-side) .
+             ((hmouse-resize-window-side) . (hmouse-resize-window-side)))
+            ;;
+            ;; Although Hyperbole can distinguish whether
+            ;; inter-window drags are between frames or not,
+            ;; having different behavior for those 2 cases could
+            ;; be confusing, so treat all modeline drags between
+            ;; windows the same and comment out this next clause.
+            ;;   Modeline drag between frames
+            ;;   ((and (hmouse-modeline-depress) (hmouse-drag-between-frames)) 
.
+            ;;    ((hmouse-clone-window-to-frame) . 
(hmouse-move-window-to-frame)))
+            ;;
+            ;; Drag with release on a Modeline
+            ((and (hmouse-modeline-release) (not (hmouse-modeline-click))) .
+             ((or (hmouse-drag-item-to-display t) (hmouse-buffer-to-window t)) 
.
+              (hmouse-swap-buffers)))
+            ;; Non-vertical Modeline drag between windows
+            ((and (hmouse-modeline-depress) (hmouse-drag-between-windows)
+                  (not (hmouse-drag-vertically-within-emacs))) .
+                  ((hmouse-buffer-to-window) . (hmouse-swap-buffers)))
+            ;; Modeline drag that ends outside of Emacs
+            ((and (hmouse-modeline-depress) (hmouse-drag-outside-all-windows)) 
.
+             ((hycontrol-clone-window-to-new-frame) . 
(hycontrol-window-to-new-frame)))
+            ;; Other Modeline click or drag
+            ((hmouse-modeline-depress) .
+             ((action-key-modeline) . (assist-key-modeline)))
+            ((hmouse-drag-between-windows) .
+             ;; Note that `hui:link-directly' uses any active
+             ;; region as the label of the button to create.
+             ((or (hmouse-drag-item-to-display) (hui:link-directly)) . 
(hmouse-swap-buffers)))
+            ((hmouse-drag-region-active) .
+             ((hmouse-drag-not-allowed) . (hmouse-drag-not-allowed)))
+            ((setq hkey-value (hmouse-drag-horizontally)) .
+             ((hmouse-horizontal-action-drag) . 
(hmouse-horizontal-assist-drag)))
+            ((hmouse-drag-vertically) .
+             ((hmouse-vertical-action-drag) . (hmouse-vertical-assist-drag)))
+            ((setq hkey-value (hmouse-drag-diagonally)) .
+             ((call-interactively #'hywconfig-ring-save) .
+              (call-interactively #'hywconfig-yank-pop)))
+            ;; Window drag that ends outside of Emacs
+            ((hmouse-drag-outside-all-windows) .
+             ((or (hmouse-drag-item-to-display)
+                  (hycontrol-clone-window-to-new-frame)) .
+                  (hycontrol-window-to-new-frame)))
+            ;;
+            ;; Now since this is not a drag and if there was an active
+            ;; region prior to when the Action or Assist Key was
+            ;; pressed, then store point at one end of the region into
+            ;; `hkey-value' and the string value of the region
+            ;; into `hkey-region' which is either yanked, or
+            ;; killed and yanked at the current point.
+            ((hmouse-prior-active-region) .
+             ((hmouse-yank-region) . (hmouse-kill-and-yank-region)))
+            ;;
+            )
+          hmouse-alist))))
 
 ;;; ************************************************************************
 ;;; Public functions
@@ -322,8 +321,8 @@ Key behavior reverts to as though no items have been 
dragged."
 (defun hmouse-drag-region-active ()
   "Return non-nil if an active region existed in the depress buffer prior to 
the depress and a drag motion has occurred."
   (save-excursion
-    (and (hmouse-goto-depress-prev-point)
-        (region-active-p)
+    (and (hmouse-goto-region-prev-point)
+        (hmouse-use-region-p)
         (or (hmouse-drag-vertically) (hmouse-drag-horizontally) 
(hmouse-drag-diagonally))
         (setq hkey-value (point)))))
 
@@ -334,105 +333,119 @@ Delimited constructs include lists, comments, strings,
  </div>.  Point must be on the start or end delimiter or in the
  case of markup pair tags, on the first character of either tag.
  For strings and comments, point must be on the first line."
-    ;; Move point back to Smart Key depress location for testing whether at a 
thing.
-    (let ((depress-args (if assist-flag assist-key-depress-args 
action-key-depress-args))
-         (release-args (if assist-flag assist-key-release-args 
action-key-release-args))
-         (marked-thing))
-      (save-excursion
-       (hmouse-goto-depress-point)
-       (if (and (not (region-active-p)) (hui-select-at-delimited-thing-p)
-                (or (markerp depress-args) (markerp release-args)
-                    (and (not (or (hmouse-drag-window-side) 
(hmouse-modeline-depress)))
-                         (or (hmouse-drag-between-windows) 
(hmouse-drag-vertically) 
-                             (hmouse-drag-horizontally) 
(hmouse-drag-diagonally))))
-                (let ((start-buf (window-buffer (smart-window-of-coords 
depress-args)))
-                      (end-buf (window-buffer (smart-window-of-coords 
release-args)))
-                      (start-point (smart-point-of-coords depress-args))
-                      (end-point (smart-point-of-coords release-args)))
-                  ;; Ignore this, if it is a click or if drag end point is 
within the thing to operate upon
-                  (not (and (eq start-buf end-buf)
-                            start-point
-                            end-point
-                            (/= start-point end-point)
-                            (setq marked-thing (hui-select-delimited-thing))
-                            (>= end-point (min (point) (mark)))
-                            (<= end-point (max (point) (mark)))))))
-           (progn (if (not (region-active-p)) (hui-select-delimited-thing))
-                  ;; Store any new value of point as a result of marking the 
region,
-                  ;; so we can return to it later.
-                  (setq hkey-value (point))
-                  (hmouse-save-region)
-                  t)
-         (if marked-thing (deactivate-mark))
-         nil))))
+  ;; Move point back to Smart Key depress location for testing whether at a 
thing.
+  (let ((depress-args (if assist-flag assist-key-depress-args 
action-key-depress-args))
+       (release-args (if assist-flag assist-key-release-args 
action-key-release-args))
+       (marked-thing)
+       (ignore-drag))
+    (save-excursion
+      (hmouse-goto-depress-point)
+      (if (and (not (hmouse-use-region-p)) (hui-select-at-delimited-thing-p)
+              (or (markerp depress-args) (markerp release-args)
+                  (and (not (or (hmouse-drag-window-side) 
(hmouse-modeline-depress)))
+                       (or (hmouse-drag-between-windows) 
(hmouse-drag-vertically) 
+                           (hmouse-drag-horizontally) 
(hmouse-drag-diagonally))))
+              (let ((start-buf (window-buffer (smart-window-of-coords 
depress-args)))
+                    (end-buf (window-buffer (smart-window-of-coords 
release-args)))
+                    (start-point (smart-point-of-coords depress-args))
+                    (end-point (smart-point-of-coords release-args)))
+                ;; If it is a click, return nil; if drag end point
+                ;; is within the thing to operate upon, don't set a
+                ;; region, so no operation will be performed but
+                ;; return t (ignore drag).
+                (not (and (eq start-buf end-buf)
+                          start-point
+                          end-point
+                          (/= start-point end-point)
+                          (setq marked-thing (hui-select-delimited-thing))
+                          (setq ignore-drag (and (> end-point (min (point) 
(mark)))
+                                                 (< end-point (max (point) 
(mark)))))))))
+         (progn (when (not (hmouse-use-region-p)) (hui-select-delimited-thing))
+                ;; Erase any saved location of a region prior to Smart Key 
depress since now we have a
+                ;; new region location.  This prevents 
hmouse-kill-and-yank-region from jumping to the
+                ;; old location.
+                (if assist-flag
+                    (setq assist-key-depress-prev-point nil)
+                  (setq action-key-depress-prev-point nil))
+                ;; Store any new value of point as a result of marking the 
region, so we can return to it
+                ;; later.
+                (setq hkey-value (point))
+                (hmouse-save-region)
+                t)
+       (if marked-thing (deactivate-mark))
+       (when ignore-drag (error "(Hyperbole): Smart Key drag of a delimited 
thing must end outside of the thing"))
+       nil))))
 
 (defun hmouse-kill-region ()
   "Kill the marked region near where the Smart Key was depressed.
 Signals an error if the depress buffer is read-only."
-  ;; Move point back to Smart Key depress buffer but not necessarily
-  ;; the same point at the depress since region selection may have
-  ;; moved it.
-  (hmouse-goto-region-point)
+  ;; Region may be in another buffer, so move there if so.
+  (hmouse-goto-region-prev-point)
   (if buffer-read-only
       ;; In this case, we want an error that will terminate execution so that
       ;; hkey-region is not reset to nil.  This allows the user to fix the
       ;; problem and then to try killing again.
       (error "(hmouse-kill-region): Use {%s} to enable killing from this 
buffer."
             (hmouse-read-only-toggle-key))
-    (kill-region (point) (mark))))
+    (kill-region (or hkey-value (point)) (mark))))
 
 (defun hmouse-kill-and-yank-region ()
   "Kill the marked region near where the Smart Key was depressed and yank it 
at the point of release.
 Signals an error if either depress or release buffer is read-only."
-  ;; Move point back to Smart Key depress buffer but not necessarily
-  ;; the same point, for testing if real-only.
-  (hmouse-goto-region-point)
-  (if buffer-read-only
-      ;; In this case, we want an error that will terminate execution so that
-      ;; hkey-region is not reset to nil.  This allows the user to fix the
-      ;; problem and then to try killing again.
-      (error "(hmouse-kill-and-yank-region): Use {%s} to enable killing from 
this buffer."
-            (hmouse-read-only-toggle-key))
-    ;; Depress and release may be in the same buffer, in which case, 
-    ;; save the release point that may change as a result of
-    ;; the kill; also, before the kill, restore the point to where it
-    ;; was when the region was set.
-    (hmouse-goto-release-point)
-    (let ((release-point (point-marker)))
-      (if buffer-read-only
-         ;; In this case, we want an error that will terminate execution so 
that
-         ;; hkey-region is not reset to nil.  This allows the user to fix the
-         ;; problem and then to try yanking again.
-         (error "(hmouse-kill-and-yank-region): Use {%s} to enable yanking 
into this buffer."
-                (hmouse-read-only-toggle-key))
-       ;; Now kill and yank the region into the Smart Key release buffer.
-       (hmouse-goto-region-point)
-       (kill-region (point) (mark))
-       ;; Permanently return to release point
-       (select-window (if assist-flag assist-key-release-window 
action-key-release-window))
-       (goto-char release-point)
-       (hmouse-insert-region)))))
+  (when hkey-region
+    ;; Move point back to Smart Key depress buffer.
+    (hmouse-goto-depress-point)
+    (if buffer-read-only
+       ;; In this case, we want an error that will terminate execution so that
+       ;; hkey-region is not reset to nil.  This allows the user to fix the
+       ;; problem and then to try killing again.
+       (error "(hmouse-kill-and-yank-region): Use {%s} to enable killing from 
this buffer."
+              (hmouse-read-only-toggle-key))
+      ;; Depress and release may be in the same buffer, in which case, 
+      ;; save the release point that may change as a result of
+      ;; the kill; also, before the kill, restore the point to where it
+      ;; was when the region was set.
+      (hmouse-goto-release-point)
+      (let ((release-point (point-marker)))
+       (if buffer-read-only
+           ;; In this case, we want an error that will terminate execution so 
that
+           ;; hkey-region is not reset to nil.  This allows the user to fix the
+           ;; problem and then to try yanking again.
+           (error "(hmouse-kill-and-yank-region): Use {%s} to enable yanking 
into this buffer."
+                  (hmouse-read-only-toggle-key))
+         ;; Region may be in another buffer, so move there if so.
+         (hmouse-goto-region-prev-point)
+         ;; Now kill and yank the region into the Smart Key release buffer.
+         (kill-region (or hkey-value (point)) (mark))
+         ;; Permanently return to release point
+         (select-window (if assist-flag assist-key-release-window 
action-key-release-window))
+         (goto-char release-point)
+         ;; Protect from indentation errors
+         (condition-case ()
+             (hmouse-insert-region)
+           (error nil)))))))
 
 (defun hmouse-yank-region ()
   "Yank the region of text saved in `hkey-region' into the current buffer.
 Signals an error if the buffer is read-only."
   ;; If a region was just selected for yanking, deactivate it as we
   ;; have already copied the region into `hkey-region'.
-  (hmouse-goto-region-point)
-  (if (region-active-p) (deactivate-mark))
-  (hmouse-goto-release-point)
-  (if buffer-read-only
-      ;; In this case, we want an error that will terminate execution so that
-      ;; hkey-region is not reset to nil.  This allows the user to fix the
-      ;; problem and then to try yanking again.
-      (error "(hmouse-yank-region): Use {%s} to enable yanking into this 
buffer."
-            (hmouse-read-only-toggle-key))
-    ;; Permanently return to release point
-    (select-window (if assist-flag assist-key-release-window 
action-key-release-window))
-    ;; Protect from indentation errors
-    (condition-case err
-       (hmouse-insert-region)
-      (error nil))))
+  (when hkey-region
+    (hmouse-goto-region-prev-point)
+    (if (region-active-p) (deactivate-mark))
+    (hmouse-goto-release-point)
+    (if buffer-read-only
+       ;; In this case, we want an error that will terminate execution so that
+       ;; hkey-region is not reset to nil.  This allows the user to fix the
+       ;; problem and then to try yanking again.
+       (error "(hmouse-yank-region): Use {%s} to enable yanking into this 
buffer."
+              (hmouse-read-only-toggle-key))
+      ;; Permanently return to release point
+      (select-window (if assist-flag assist-key-release-window 
action-key-release-window))
+      ;; Protect from indentation errors
+      (condition-case ()
+         (hmouse-insert-region)
+       (error nil)))))
 
 (defun hmouse-drag-between-frames ()
   "Returns non-nil if last Action Key depress and release were in different 
frames.
@@ -742,13 +755,13 @@ With optional boolean NEW-WINDOW non-nil, sensibly split 
the release window befo
 (defun hmouse-set-buffer-and-point (buffer point)
   (when buffer
     (set-buffer buffer)
-    (if point (goto-char point))))
+    (when point (goto-char point))))
 
-(defun hmouse-goto-depress-prev-point ()
-  "Temporarily set point to where the last Smart Key was depressed and return 
t, else nil if no such point saved."
+(defun hmouse-goto-region-prev-point ()
+  "Temporarily set point to where it was prior to the last Smart Key depress 
and return t, else nil if no such point is saved."
   (let* ((prev-point (if assist-flag assist-key-depress-prev-point 
action-key-depress-prev-point))
         (buf (and prev-point (marker-buffer prev-point)))
-        (loc (marker-position prev-point)))
+        (loc (and prev-point (marker-position prev-point))))
     (when (and buf loc)
       (hmouse-set-buffer-and-point buf loc)
       t)))
@@ -759,14 +772,8 @@ With optional boolean NEW-WINDOW non-nil, sensibly split 
the release window befo
        (loc (smart-point-of-coords (if assist-flag assist-key-depress-args 
action-key-depress-args))))
     (hmouse-set-buffer-and-point buf loc)))
 
-(defun hmouse-goto-region-point ()
-  "Temporarily set point back to where it was when the region was activated 
prior to last Smart Key depress."
-  (let* ((loc (if assist-flag assist-key-depress-prev-point 
action-key-depress-prev-point))
-        (buf (marker-buffer loc)))
-    (hmouse-set-buffer-and-point buf loc)))
-
 (defun hmouse-goto-release-point ()
-  "Temporarily set point to where the last Smart Key was depressed."
+  "Temporarily set point to where the last Smart Key was released."
   (let ((buf (window-buffer (if assist-flag assist-key-release-window 
action-key-release-window)))
        (loc (smart-point-of-coords (if assist-flag assist-key-release-args 
action-key-release-args))))
     (hmouse-set-buffer-and-point buf loc)))
diff --git a/hui-xe-but.el b/hui-xe-but.el
index a3210db..7e216ac 100644
--- a/hui-xe-but.el
+++ b/hui-xe-but.el
@@ -117,6 +117,13 @@ highlighted."
                (hproperty:but-add start end hproperty:but-face))
              start-delim end-delim regexp-match 'include-delims)))
 
+(defun hproperty:but-create-on-yank (prop-value start end)
+  (save-restriction
+    (narrow-to-region start end)
+    (hproperty:but-create-all)))
+
+(add-to-list 'yank-handled-properties '(hproperty:but-face . 
hproperty:but-create-on-yank))
+
 (defun hproperty:but-delete (&optional pos)
   (let ((extent (extent-at (or pos (point)))))
     (if extent (delete-extent extent))))



reply via email to

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