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

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

[elpa] externals/hyperbole 70b6a79 29/53: Added modeline drag to window


From: Robert Weiner
Subject: [elpa] externals/hyperbole 70b6a79 29/53: Added modeline drag to window to replace dest. buffer with source buffer; showed Hyperbole key bindings in menu
Date: Wed, 15 Nov 2017 22:47:03 -0500 (EST)

branch: externals/hyperbole
commit 70b6a79447b52cd914386b4c78795d33b729cbef
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>

    Added modeline drag to window to replace dest. buffer with source buffer; 
showed Hyperbole key bindings in menu
    
    * hui-window.el (hmouse-drag-between-frames): Removed from hmouse-alist; 
treat this context
        the same as a drag between windows within one frame, for consistency.
    
    * hui-menu.el (hui-menu-key-bindings): Added for use as menu filter for 
Hyperbole/Options/Change-Key-Bindings
        so displayed key bindings are always up-to-date.
    
    * hui-mouse.el (smart-outline-level): Added and used instead of 
(outline-level) which assumes
        its caller has already generated match data, which is not always the 
case in Hyperbole.
    
    * hmouse-sh.el (hmouse-move-point-emacs): Added 
mouse-select-region-move-to-beginning handling
        that appeared in Emacs 26.1 and noted this in the function 
documentation.
    
    * hui-window.el (hmouse-buffer-to-window): Added along with drag from 
mode-line to another
        window context to replace the buffer in a dest. window with the buffer 
from the source
        window.
---
 Changes           | 20 +++++++++++++++++++-
 hmouse-sh.el      |  9 +++++++--
 hui-menu.el       | 40 ++++++++++++++++++++--------------------
 hui-mouse.el      | 26 ++++++++++++++------------
 hui-window.el     | 23 +++++++++++++++++++----
 man/hkey-help.txt |  3 ++-
 topwin            |  3 +++
 7 files changed, 84 insertions(+), 40 deletions(-)

diff --git a/Changes b/Changes
index 4a47140..964b5d5 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,21 @@
+2017-10-16  Bob Weiner  <address@hidden>
+
+* hui-window.el (hmouse-drag-between-frames): Removed from hmouse-alist; treat 
this context
+    the same as a drag between windows within one frame, for consistency.
+
+* hui-menu.el (hui-menu-key-bindings): Added for use as menu filter for 
Hyperbole/Options/Change-Key-Bindings
+    so displayed key bindings are always up-to-date.
+
+* hui-mouse.el (smart-outline-level): Added and used instead of 
(outline-level) which assumes
+    its caller has already generated match data, which is not always the case 
in Hyperbole.
+
+* hmouse-sh.el (hmouse-move-point-emacs): Added 
mouse-select-region-move-to-beginning handling
+    that appeared in Emacs 26.1 and noted this in the function documentation.
+
+* hui-window.el (hmouse-buffer-to-window): Added along with drag from 
mode-line to another
+    window context to replace the buffer in a dest. window with the buffer 
from the source
+    window.
+
 ----
 
 2017-10-16  Bob Weiner  <address@hidden>
@@ -22,7 +40,7 @@
     obscured by another application or not.
                 (hmouse-verify-release-window-flag): Added so can turn off use 
of the macOS
     Python script when desired since it slows Smart Key action handling at 
least 1/3 of a
-    second. 
+    second.
 
 * hycontrol.el (hycontrol-frames): Changed = command call to set-frame-size to 
use pixel
     dimensions rather than chars/lines for better accuracy.
diff --git a/hmouse-sh.el b/hmouse-sh.el
index 383d951..64982cb 100644
--- a/hmouse-sh.el
+++ b/hmouse-sh.el
@@ -411,7 +411,8 @@ These may be the bindings prior to initializing Hyperbole 
or the Hyperbole bindi
   "Move point to the position clicked on with the mouse.
 This should be bound to a mouse click event type.
 If PROMOTE-TO-REGION is non-nil and event is a multiple-click,
-select the corresponding element around point."
+select the corresponding element around point, with the resulting position of
+point determined by `mouse-select-region-move-to-beginning'."
   (interactive "e\np")
   (let ((start-w-or-f (posn-window (event-start event)))
        (end-w-or-f   (posn-window (event-end event))))
@@ -426,7 +427,11 @@ select the corresponding element around point."
       ;; Give temporary modes such as isearch a chance to turn off.
       (run-hooks 'mouse-leave-buffer-hook)
       (if (and promote-to-region (> (event-click-count event) 1))
-         (mouse-set-region event)
+         (progn (mouse-set-region event)
+                (when (and (boundp 'mouse-select-region-move-to-beginning)
+                           mouse-select-region-move-to-beginning)
+                  (when (> (posn-point (event-start event)) (region-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)
diff --git a/hui-menu.el b/hui-menu.el
index 0d2da90..a8a628a 100644
--- a/hui-menu.el
+++ b/hui-menu.el
@@ -124,7 +124,19 @@ Return t if cutoff, else nil."
 
 (defun hui-menu-key-binding-item (item-name command)
   "Return a key binding menu item string built from ITEM-NAME and COMMAND."
-  (format "%-30s {%s}" item-name (key-description (car (where-is-internal 
command)))))
+  (format "%s(%s)" item-name (key-description (where-is-internal command nil 
t))))
+
+(defun hui-menu-key-bindings (rest-of-menu)
+  (nconc
+   (list
+    (vector (hui-menu-key-binding-item "Action-Key         \t\t\t" 
'hkey-either)       '(hui:bind-key #'hkey-either) t)        ;; {M-RET}
+    (vector (hui-menu-key-binding-item "Button-Rename-Key  \t\t"   
'hui:ebut-rename)   '(hui:bind-key #'hui:ebut-rename) t)    ;; {C-c C-r}
+    (vector (hui-menu-key-binding-item "Drag-Emulation-Key \t\t"   
'hkey-operate)      '(hui:bind-key #'hkey-operate) t)       ;; {M-o}
+    (vector (hui-menu-key-binding-item "Hyperbole-Menu-Key \t"     'hyperbole) 
        '(hui:bind-key #'hyperbole) t)          ;; {C-h h}
+    (vector (hui-menu-key-binding-item "Mark-Thing-Key     \t\t"   
'hui-select-thing)  '(hui:bind-key #'hui-select-thing) t)   ;; {C-c C-m}
+    (vector (hui-menu-key-binding-item "Smart-Help-Key     \t\t"   'hkey-help) 
        '(hui:bind-key #'hkey-help) t)          ;; {C-h A}
+    (vector (hui-menu-key-binding-item "Windows-Control-Key\t"     
'hycontrol-windows) '(hui:bind-key #'hycontrol-windows) t)) ;; {C-C \}
+   rest-of-menu))
 
 ;; Dynamically compute submenus for Screen menu
 (defun hui-menu-screen (_ignored)
@@ -140,13 +152,11 @@ Return t if cutoff, else nil."
 
 (defun hui-menu-web-search ()
   ;; Pulldown menu
-  (let ((web-pulldown-menu
-        (mapcar (lambda (service)
-                  (vector service
-                          (list #'hyperbole-web-search service nil)
-                          t))
-                (mapcar 'car hyperbole-web-search-alist))))
-    web-pulldown-menu))
+  (mapcar (lambda (service)
+           (vector service
+                   (list #'hyperbole-web-search service nil)
+                   t))
+         (mapcar 'car hyperbole-web-search-alist)))
 
 ;;; ************************************************************************
 ;;; Public variables
@@ -199,17 +209,7 @@ Return t if cutoff, else nil."
             :style toggle
             :selected hpath:find-file-urls-mode]
            "----")
-         (list (list "Change-Key-Bindings"
-                     (vector (hui-menu-key-binding-item "Action-Key"          
'hkey-either)       '(hui:bind-key #'hkey-either)
-                             :key-sequence "M-RET"
-                             :selected t)            ;; {M-RET}
-                     (vector (hui-menu-key-binding-item "Button-Rename-Key"   
'hui:ebut-rename)   '(hui:bind-key #'hui:ebut-rename) t)        ;; {C-c C-r}
-                     (vector (hui-menu-key-binding-item "Drag-Emulation-Key"  
'hkey-operate)      '(hui:bind-key #'hkey-operate) t)           ;; {M-o}
-                     (vector (hui-menu-key-binding-item "Hyperbole-Menu-Key"  
'hyperbole)         '(hui:bind-key #'hyperbole) t)              ;; {C-h h}
-                     (vector (hui-menu-key-binding-item "Mark-Thing-Key"      
'hui-select-thing)  '(hui:bind-key #'hui-select-thing) t)       ;; {C-c C-m}
-                     (vector (hui-menu-key-binding-item "Smart-Help-Key"      
'hkey-help)         '(hui:bind-key #'hkey-help) t)              ;; {C-h A}
-                     (vector (hui-menu-key-binding-item "Windows-Control-Key" 
'hycontrol-windows) '(hui:bind-key #'hycontrol-windows) t)      ;; {C-C \}
-                     ))
+         '(("Change-Key-Bindings" :filter hui-menu-key-bindings))
          '("----")
          (list (cons "Display-Referents-in"
                      (mapcar (lambda (sym)
@@ -379,7 +379,7 @@ REBUILD-FLAG is non-nil, in which case the menu is rebuilt."
                   ["Types"
                    (hui:htype-help-current-window 'actypes) t]
                   )
-                (nconc
+                (append
                  '("Find"
                    ["Manual"   (id-info-item "menu, Find") t]
                    "----"
diff --git a/hui-mouse.el b/hui-mouse.el
index 469f365..ef03144 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -1288,6 +1288,13 @@ If not on a file name, returns nil."
                             (setq smart-outline-cut nil))))
          '(outline-mode-hook outline-minor-mode-hook)))
 
+(defun smart-outline-level ()
+  "Return current outline level if point is on a line that begins with 
`outline-regexp'."
+  (save-excursion
+    (beginning-of-line)
+    (when (looking-at outline-regexp)
+      (funcall outline-level))))
+
 (defun smart-outline ()
   "Collapses, expands, and moves outline entries.
 Invoked via a key press when in outline-mode.  It assumes that
@@ -1316,10 +1323,9 @@ If key is pressed:
          (or (outline-get-next-sibling)
              ;; Skip past start of current entry
              (progn (re-search-forward outline-regexp nil t)
-                    (smart-outline-to-entry-end t (outline-level))))))
+                    (smart-outline-to-entry-end t (funcall outline-level))))))
 
-       ((or (eolp) (zerop (save-excursion (beginning-of-line)
-                                          (outline-level))))
+       ((or (eolp) (zerop (smart-outline-level)))
         (funcall action-key-eol-function))
        ;; On an outline heading line but not at the start/end of line.
        ((smart-outline-subtree-hidden-p)
@@ -1354,29 +1360,25 @@ If assist-key is pressed:
                      ;; Skip past start of current entry
                      (progn (re-search-forward outline-regexp nil t)
                             (smart-outline-to-entry-end
-                             nil (outline-level)))))
-       ((or (eolp) (zerop (save-excursion (beginning-of-line)
-                                          (outline-level))))
+                             nil (funcall outline-level)))))
+       ((or (eolp) (zerop (smart-outline-level)))
         (funcall assist-key-eol-function))
        ;; On an outline heading line but not at the start/end of line.
        ((smart-outline-subtree-hidden-p)
         (outline-show-entry))
        (t (outline-hide-entry))))
 
-(defun smart-outline-to-entry-end
-  (&optional include-sub-entries curr-entry-level)
+(defun smart-outline-to-entry-end (&optional include-sub-entries 
curr-entry-level)
   "Goes to end of whole entry if optional INCLUDE-SUB-ENTRIES is non-nil.
 CURR-ENTRY-LEVEL is an integer representing the length of the current level
 string which matched to `outline-regexp'.  If INCLUDE-SUB-ENTRIES is nil,
 CURR-ENTRY-LEVEL is not needed."
   (let (next-entry-exists)
-    (while (and (setq next-entry-exists
-                     (re-search-forward outline-regexp nil t))
+    (while (and (setq next-entry-exists (re-search-forward outline-regexp nil 
t))
                include-sub-entries
                (save-excursion
                  (beginning-of-line)
-                 (> (outline-level)
-                    curr-entry-level))))
+                 (> (funcall outline-level) curr-entry-level))))
     (if next-entry-exists
        (progn (beginning-of-line) (point))
       (goto-char (point-max)))))
diff --git a/hui-window.el b/hui-window.el
index 9cacbdc..4389c34 100644
--- a/hui-window.el
+++ b/hui-window.el
@@ -28,13 +28,14 @@
 ;;
 ;; Drag buffer/file menu item      Display buffer/file there   Swap window 
buffers
 ;;   to another window
+;; Modeline drag to another window Replace dest. buffer with   Swap window 
buffers
+;;                                   source buffer
 ;; Other drag between windows      Create/modify a link but    Swap window 
buffers
 ;; Drag buffer/file menu item      Display buffer/file
 ;;   outside of Emacs                in a new frame            Move window to 
a new frame
 ;;
 ;; Modeline or other window drag   Clone window to a new frame Move window to 
a new frame
 ;;   outside of Emacs              
-;; Modeline drag to another frame  Clone window to other frame Move window to 
other frame  
 ;; Modeline depress & wind release Resize window height        <- same
 ;; Click in modeline
 ;;     Left modeline edge          Bury buffer                 Unbury bottom 
buffer
@@ -163,9 +164,19 @@ drag release window.")
                 ((hmouse-yank-region) . (hmouse-kill-and-yank-region)))
                ((hmouse-drag-window-side) .
                 ((hmouse-resize-window-side) . (hmouse-resize-window-side)))
-               ;; Modeline drag between frames
-               ((and (hmouse-modeline-depress) (hmouse-drag-between-frames)) .
-                ((hmouse-clone-window-to-frame) . 
(hmouse-move-window-to-frame)))
+               ;;
+               ;; 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)))
+               ;;
+               ;; Modeline drag between windows
+               ((and (hmouse-modeline-depress) (hmouse-drag-between-windows)) .
+                ((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)))
@@ -634,6 +645,10 @@ Ignores minibuffer window."
 ;;; Private functions
 ;;; ************************************************************************
 
+(defun hmouse-buffer-to-window ()
+  "Invoked via drag, replace the buffer in the Action Key release window with 
the buffer from the Action Key depress window."
+  (set-window-buffer action-key-release-window (window-buffer 
action-key-depress-window)))
+
 (defun hmouse-drag-not-allowed ()
   "Display an error when a region is active and in-window drags are not 
allowed."
   ;; Return point to where it was prior to depress so the region does not 
permanently change.
diff --git a/man/hkey-help.txt b/man/hkey-help.txt
index b4e9c4d..a89673b 100644
--- a/man/hkey-help.txt
+++ b/man/hkey-help.txt
@@ -33,13 +33,14 @@ Mouse-only Control
 
   Drag between windows from     Displays buffer/file in    Swaps window buffers
     buffer/file menu item         window of button release 
+  Modeline drag to another      Replaces dest. buffer with Swaps window buffers
+    window                        source buffer
   Other drag between windows    Creates/modifies a link    Swaps window buffers
   Drag to outside Emacs from    Displays buffer/file in    Moves window to new 
frame
     buffer/file menu item         a new frame
 
   Modeline or other window drag
     outside of Emacs            Clones window to new frame Moves window to new 
frame
-  Modeline drag to other frame  Clones window to frame     Moves window to 
frame
   Modeline depress+wind release Resizes window height      <- same
   Modeline Click
     Left modeline edge          Buries current buffer      Unburies bottom 
buffer
diff --git a/topwin b/topwin
index b6f3dce..2892cad 100755
--- a/topwin
+++ b/topwin
@@ -8,6 +8,9 @@
 # AUTHOR:       Bob Weiner <address@hidden>
 # ORIG-DATE:    14-Oct-17 at 16:21:53
 #
+# Copyright (C) 2017  Free Software Foundation, Inc.
+# See the "HY-COPY" file for license information.
+#
 # DESCRIPTION:  
 # DESCRIP-END.
 



reply via email to

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