branch: externals/hyperbole commit 414ef9413b353bea80d9105b12d6ff1a2b3e13aa Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Update for treemacs compatibility; {M-o i} push button fixes --- Changes | 18 +++++++++++++-- hmouse-drv.el | 21 ++++++++++-------- hpath.el | 7 +++--- hsys-org.el | 5 +---- hui-mouse.el | 2 +- hui-treemacs.el | 42 ++++++++++++++++------------------- hui-window.el | 37 ++++++++++++++++--------------- hyperbole.el | 10 +++++++++ man/hyperbole.texi | 64 ++++++++++++++++++++++++++++++++++++------------------ topwin.py | 2 +- 10 files changed, 125 insertions(+), 83 deletions(-) diff --git a/Changes b/Changes index 42983b1..b6d9a4f 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,21 @@ +2019-02-16 Bob Weiner <r...@gnu.org> + +* hui-window.el (smart-window-of-coords): Handled null coords parameter. + +2019-02-10 Bob Weiner <r...@gnu.org> + +* hmouse-drv.el (hkey-drag-to): Fixed to match documentation that says will + create an explicit file link button if called anywhere other than on + a listing item. + +* hui-treemacs.el (smart-treemacs-modeline): Replaced old call of + treemacs-buffer-exists? with new calls to treemacs-current-visibility + and treemacs-get-local-buffer for Treemacs V2. + 2019-02-06 Bob Weiner <r...@gnu.org> -* hibtypes.el (ripgrep-msg): Tighted match to ignore empty potential filenames - that matched when they expanded to the current directory. +* hibtypes.el (ripgrep-msg): Tightened match to ignore empty potential filenames + that matched when they were expanded to the current directory. 2019-02-05 Bob Weiner <r...@gnu.org> diff --git a/hmouse-drv.el b/hmouse-drv.el index 507594b..968bf8f 100644 --- a/hmouse-drv.el +++ b/hmouse-drv.el @@ -337,7 +337,7 @@ bound to a valid function." The ace-window package, (see \"https://elpa.gnu.org/packages/ace-window.html\"), assigns short ids to each Emacs window and lets you jump to or -operate upon a specific window by giving its letter. Hyperbole +operate upqon a specific window by giving its letter. Hyperbole can insert an operation into ace-window that allows you to display items such as dired or buffer menu items in a specific window. @@ -447,14 +447,17 @@ Works only when running under a window system, not from a dumb terminal." ;; Leave release-window selected (when (window-live-p release-window) (hypb:select-window-frame release-window))) - (if (eq start-window release-window) - ;; Leave hkey-drag to choose final selected window - (hkey-drag release-window) - ;; Replace release window's buffer with selected - ;; window's buffer. - (hkey-buffer-to start-window release-window) - (when (window-live-p release-window) - (hypb:select-window-frame release-window)))))) + ;; Leave hkey-drag to choose final selected window + (hkey-drag release-window) + ;; (if (eq start-window release-window) + ;; ;; Leave hkey-drag to choose final selected window + ;; (hkey-drag release-window) + ;; ;; Replace release window's buffer with selected + ;; ;; window's buffer. + ;; (hkey-buffer-to start-window release-window) + ;; (when (window-live-p release-window) + ;; (hypb:select-window-frame release-window))) + ))) ;;;###autoload (defun hkey-replace (release-window) diff --git a/hpath.el b/hpath.el index 2eebd1f..cd7d80a 100644 --- a/hpath.el +++ b/hpath.el @@ -173,7 +173,7 @@ Path must be a string or an error will be triggered. See "Returns result of applying FUNC of two args, key and value, to key-value pairs in PLIST, a property list." (cl-loop for (k v) on plist by #'cddr collect (funcall func k v) into result - return result)) + finally return result)) ;;;###autoload (defun hpath:cache-mswindows-mount-points () @@ -197,8 +197,7 @@ Call this function manually if mount points change after Hyperbole is loaded." (setq path (concat "/" (downcase (match-string 1 path))))) (cons path mount-point)) ;; Return a plist of MSWindows path-mounted mount-point pairs. - (split-string (shell-command-to-string - (format "df 2> /dev/null | grep -v '%s' | sed -e 's/ .*%%//g'" hpath:posix-mount-points-regexp)))) + (split-string (shell-command-to-string (format "df -a -t drvfs 2> /dev/null | sort | uniq | grep -v '%s' | sed -e 's+ .*[-%%] /+ /+g'" hpath:posix-mount-points-regexp)))) (lambda (cons1 cons2) (<= (length (car cons1)) (length (car cons2))))))))) @@ -980,7 +979,7 @@ See also `hpath:internal-display-alist' for internal, window-system independent (cons "next" hpath:external-display-alist-macos))))))) (defun hpath:is-p (path &optional type non-exist) - "Returns PATH if PATH is a Posix path, else nil. + "Returns PATH if PATH is a Posix or MSWindows path, else nil. If optional TYPE is the symbol 'file or 'directory, then only that path type is accepted as a match. The existence of the path is checked only for locally reachable paths (Info paths are not checked). Single spaces are diff --git a/hsys-org.el b/hsys-org.el index 1056d24..59a1eb1 100644 --- a/hsys-org.el +++ b/hsys-org.el @@ -46,10 +46,7 @@ ;;; ************************************************************************ (defib org-mode () - "Follows any Org mode link at point or cycles through views of the outline subtree at point. -The variable, `browse-url-browser-function', customizes the url browser that -is used for urls. Valid values of this variable include `browse-url-default-browser' -and `browse-url-generic'." + "Follows any Org mode link at point or cycles through views of the outline subtree at point." (when (derived-mode-p 'org-mode) (cond ((org-link-at-p) (hact 'org-link nil)) diff --git a/hui-mouse.el b/hui-mouse.el index 7fc9759..cc1cd45 100644 --- a/hui-mouse.el +++ b/hui-mouse.el @@ -636,7 +636,7 @@ If assist-key is pressed: (defun smart-company-to-definition (event) "Action Key binding for company-mode completions popup to show item definition. -Use left mouse key or RET key to select a completion and exit." +Use left mouse key, RET or TAB key to select a completion and exit." (interactive "e") (when (mouse-event-p last-command-event) (company-select-mouse event)) diff --git a/hui-treemacs.el b/hui-treemacs.el index 4b750b4..2cdface 100644 --- a/hui-treemacs.el +++ b/hui-treemacs.el @@ -84,28 +84,24 @@ quit/hide the Treemacs window. Otherwise, display the Treemacs window with the default directory of the buffer modeline clicked upon. Suitable for use as a value of `action-key-modeline-buffer-id-function'." - (if (fboundp 'treemacs) - (progn - (require 'treemacs) - (cond - ;; Clicked on Treemacs buffer id - ((if action-key-depress-window - (treemacs-is-treemacs-window? action-key-depress-window) - (string-match " Treemacs " (format-mode-line mode-line-format))) - ;; Quit/hide treemacs. - (treemacs-quit)) - ;; - ;; Treemacs is visible and displaying the same dir as - ;; the default dir of the clicked on modeline. - ((and (treemacs-buffer-exists?) - (string-equal (expand-file-name default-directory) - (with-current-buffer (treemacs-buffer-exists?) - default-directory))) - ;; Quit/hide treemacs. - (treemacs-quit)) - ;; - ;; Otherwise, invoke treemacs on the default dir of the clicked on modeline. - (t (treemacs)))) - (error "(smart-treemacs-modeline): Treemacs package is not installed"))) + (cond + ;; Clicked on Treemacs buffer id + ((if action-key-depress-window + (treemacs-is-treemacs-window? action-key-depress-window) + (string-match " Treemacs " (format-mode-line mode-line-format))) + ;; Quit/hide treemacs. + (treemacs-quit)) + ;; + ;; Treemacs is visible and displaying the same dir as + ;; the default dir of the clicked on modeline. + ((and (eq (treemacs-current-visibility) 'visible) + (string-equal (expand-file-name default-directory) + (with-current-buffer (treemacs-get-local-buffer) + default-directory))) + ;; Quit/hide treemacs. + (treemacs-quit)) + ;; + ;; Otherwise, invoke treemacs on the default dir of the clicked on modeline. + (t (treemacs)))) (provide 'hui-treemacs) diff --git a/hui-window.el b/hui-window.el index a77faff..e904ed0 100644 --- a/hui-window.el +++ b/hui-window.el @@ -725,24 +725,25 @@ Ignores minibuffer window." (defun smart-window-of-coords (coords) "Returns window in which COORDS fall or nil if none. Ignores minibuffer window." - (cond ((markerp coords) - (get-buffer-window (marker-buffer coords))) - ((and hyperb:emacs-p (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))) - w-or-f)) - ((if (featurep 'xemacs) - (if (eventp coords) - (event-window coords) - (car coords)))) - (t (let ((window-list (hypb:window-list 'no-minibuf)) - (window) - (w)) - (while (and (not window) window-list) - (setq w (car window-list) - window-list (cdr window-list) - window (smart-coords-in-window-p coords w))) - window)))) + (when coords + (cond ((markerp coords) + (get-buffer-window (marker-buffer coords))) + ((and hyperb:emacs-p (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))) + w-or-f)) + ((if (featurep 'xemacs) + (if (eventp coords) + (event-window coords) + (car coords)))) + (t (let ((window-list (hypb:window-list 'no-minibuf)) + (window) + (w)) + (while (and (not window) window-list) + (setq w (car window-list) + window-list (cdr window-list) + window (smart-coords-in-window-p coords w))) + window))))) ;;; ************************************************************************ ;;; Private functions diff --git a/hyperbole.el b/hyperbole.el index 6a13e2f..4aa427d 100644 --- a/hyperbole.el +++ b/hyperbole.el @@ -355,6 +355,16 @@ bindings after load)." ;;; Load Hyperbole mouse bindings ;;; ************************************************************************ +;; From mouse-position.c in Emacs: +;; f = SELECTED_FRAME (); +;; XSETFRAME (lispy_dummy, f); +;; +;; It seems like the XSETFRAME macro is not properly copying the value of f on initial frame selection under the macOS window system. +;; The problem occurs on other systems as well, e.g. Emacs 25.2 under Windows 7. +;; +;; Hyperbole resolves this problem by setting the +;; `mouse-position-function' variable below to properly set the +;; newly selected frame. (if (boundp 'mouse-position-function) (setq mouse-position-function (lambda (frame-x-dot-y) diff --git a/man/hyperbole.texi b/man/hyperbole.texi index 480be1b..219863f 100644 --- a/man/hyperbole.texi +++ b/man/hyperbole.texi @@ -1179,7 +1179,7 @@ on the last line to end the dired session (bury its buffer). If you use the Treemacs file viewer Emacs package, you can configure Hyperbole to use this instead of Dired when you click on a modeline buffer id. -Since this is a customization option, it may be change permanently like so. +Since this is a customization option, it may be changed permanently like so. Use @bkbd{M-x customize-set-variable @key{RET} action-key-modeline-buffer-id-function @key{RET}}. Change the value to @code{smart-treemacs-modeline}. Then press @key{RET}. To change it back to Hyperbole's default, use the value, @code{dired-jump}. @@ -1409,14 +1409,15 @@ unless it is the only window in that frame. @cindex drag, dired item @cindex drag, buffer menu item @cindex drag, Treemacs item -You can do the same thing with items in dired, buffer menu and ibuffer menu -listing buffers rather than buffers themselves. Drag with the Action Mouse Key -and the selected item will be displayed in any Emacs window in which you -release. Drag outside Emacs and it will be displayed in a new frame. To -display the last item you want, press the Action Key on it and it will display -within the listing window itself. (If you use the Treemacs file viewer package, -item dragging works there as well). Remember that you can emulate these drags -from the keyboard when needed, @pxref{Keyboard Drags}. +You can also drag items to other windows with the Action Key in Dired, +Buffer Menu, Ibuffer and Treemacs listing buffers, rather than the +buffers themselves. Drag with the Action Mouse Key and the selected +item will be displayed in any Emacs window in which you release. Drag +outside Emacs and it will be displayed in a new frame. To display the +last item you want within the listing window itself, press and release +the Action Key on that item after dragging your other items to their +respective windows. Remember that you can emulate these drags from +the keyboard when needed, @pxref{Keyboard Drags}. So now you can put a bunch of buffers and files on your screen wherever you like. Typically, a brief visual pulse is shown first at the source item and @@ -1450,26 +1451,30 @@ session since drag actions are not supported without a window system. @cindex window by letter @cindex jump to window by letter @cindex keyboard, jump to window -For even faster keyboard-based display of items, use the Emacs -package @code{ace-window} (see @url{https://elpa.gnu.org/packages/ace-window.html}). +For even faster keyboard-based display of items and drag emulations, +use the Emacs package @code{ace-window} +(see @url{https://elpa.gnu.org/packages/ace-window.html}). The ace-window package assigns short letter IDs to each Emacs window and lets you jump to or operate upon a specific window by giving its ID. Hyperbole can add commands to ace-window that replace the two-step drag emulation key -described above with a single key sequence that displays dired or -buffer menu @emph{items}. +described above with a single key sequence that does not require moving to +the drag target window since it is specified by ID as part of the command. To enable this feature, in your Emacs initialization file after Hyperbole is initialized, if you do not have a key bound for @code{ace-window}, then call: @code{(hkey-ace-window-setup \"\M-o\")} -to bind it to @bkbd{M-o}. Otherwise, call the setup function without -a key: @code{(hkey-ace-window-setup)}. +to bind it to @bkbd{M-o}, replacing Hyperbole's +default @code{hkey-operate} command there (because ace-window can emulate +the drags performed by @code{hkey-operate}). If you already have a key bound +for @code{ace-window}, then just ensure it is initialized by calling +@code{(hkey-ace-window-setup)} without a key argument. @cindex link creation from keyboard @cindex keyboard link creation @kindex M-o i <window-id> -@kindex M-o r <window-id> @kindex M-o m <window-id> +@kindex M-o r <window-id> @kindex M-o t <window-id> @cindex drag item @cindex replace window buffer @@ -1492,6 +1497,23 @@ the selected window's buffer with that of another window, use @emph{swap} the selected window's buffer with that of another window, use @bkbd{M-o m <id-of-window-to-swap-with>}. +In summary: +@table @bkbd +@item M-o i <window> +insert listing item at point into <window>; if not on a listing item, +prompt for a name to give to a new explicit button at point that will +link to the current position in <window> + +@item M-o m <window> +swap the buffers in the selected window and <window> + +@item M-o r <window> +replace the selected (current) window's buffer with that of <window> + +@item M-o t <window> +throw listing item at point or current buffer to <window> +@end table + @c ------- @c @node Smart Mouse Key Modifiers, , Smart Mouse Key Drags, Smart Keys @@ -2043,7 +2065,7 @@ produced by git log. @vindex hibtypes-github-default-user @item github-reference Displays the Github entity associated with REFERENCE and optional USER and PROJECT. -See @file{DEMO#Github (Remote) References} for examples. +See @file{../DEMO#Github (Remote) References} for examples. REFERENCE is a string of one of the following forms: @itemize @bullet @@ -7889,10 +7911,10 @@ When in a Treemacs file browser buffer: collapse the entry; (2) elsewhere within an entry line, the item is displayed for editing, normally in another window; - (3) at the end of an entry line: invoke @code{action-key-eol-function}, - typically to scroll up proportionally, if an Action Key press; invoke - @code{assist-key-eol-function}, typically to scroll down proportionally, - if an Assist Key press; + (3) at the end of an entry line: if an Action Key press, invokes + @code{action-key-eol-function}, typically to scroll up proportionally; + if an Assist Key press, invokes @code{assist-key-eol-function}, typically + to scroll down proportionally; (4) on the first line of the buffer (other than the end of line), dired is run on the current directory of this Treemacs; (5) at the end of the first or last line of the buffer, diff --git a/topwin.py b/topwin.py index 2892cad..2a3c983 100644 --- a/topwin.py +++ b/topwin.py @@ -23,7 +23,7 @@ if len(argv) < 3: x = int(argv[1]); y = int(argv[2]) -# Return the first window only that x,y falls within since the windows are listed in z-order (top of stack to bottom) +# Return the first window that x,y falls within since the windows are listed in z-order (top of stack to bottom) def filter_and_print_top_window(x, y): win_x = win_y = win_width = win_height = 0