Skip to content

Commit 9ebfcfe

Browse files
authored
Merge pull request #602 from rswgnu/rsw
Support latest Treemacs and HyWiki page navigation with it
2 parents 498f287 + 742ccea commit 9ebfcfe

12 files changed

+372
-128
lines changed

ChangeLog

+73-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
2024-11-10 Bob Weiner <[email protected]>
2+
3+
* hui-window.el (action-key-modeline-left-edge-function,
4+
action-key-modeline-left-edge-function,
5+
assist-key-modeline-left-edge-function,
6+
action-key-modeline-right-edge-function): Add these
7+
customizations.
8+
(action-key-modeline-click-left-edge,
9+
assist-key-modeline-click-left-edge,
10+
action-key-modeline-click-right-edge,
11+
assist-key-modeline-click-right-edge): Add these functions
12+
as defaults for the above customizations.
13+
(hmouse-modeline-default-help-echo): Replacement for default
14+
'mode-line-default-help-echo' function that produces mode line hover doc
15+
for the Smart Mouse Keys.
16+
hyperbole.el (hyperbole--enable-mode): Update mode-line hover doc in blank
17+
areas for button-2 and button-3 if using unshifted Smart Keys.
18+
19+
* hui-jmenu.el (hui-menu-modeline): Add HyWiki-Edit-Pages to display a list
20+
of HyWiki page files either in dired or Treemacs.
21+
22+
* hui-treemacs.el (require): Prompt to install package if not yet installed.
23+
24+
* hui-window.el (hmouse-horizontal-assist-drag): Fix doc when one window only.
25+
26+
* man/hyperbole.texi (HyWiki Menu): Add index entries per menu item.
27+
28+
* hywiki.el (hywiki-directory-edit): Rename to 'hywiki-directory-dired-edit'.
29+
(hywiki-directory-edit): Make a new version that supports
30+
'treemacs' when 'action-key-modeline-buffer-id-function' is set to
31+
'smart-treemacs-modeline.
32+
33+
* hui-treemacs.el (smart-treemacs): Simplify and no longer call
34+
'treemacs-node-buffer-and-position' which can trigger a marker error.
35+
(smart-treemacs-edit): Add to edit/display a dir in Treemacs.
36+
(smart-treemacs-modeline): Call above function.
37+
hywiki.el (hywiki-directory-treemacs-edit): Add and call above function.
38+
39+
* hycontrol.el (hycontrol-window-display-buffer): Fix to ignore any dedicated
40+
windows and prevent an error typically generated when calling this from
41+
'walk-windows' called within 'hycontrol-windows-grid'. Makes window grids
42+
work with Treemacs display, for example.
43+
44+
* hui-treemacs.el (smart-treemacs): Fix invocation of TAB command on first line
45+
entry (treat it like any other line except at eol). Also, actually invoke
46+
latest treemacs TAB command when defined rather that calling the default
47+
command normally configured to the TAB key. Ensure all func calls are
48+
wrapped with 'hact'.
49+
(smart-treemacs-modeline): Ensure always displays just the
50+
dir associated with the current buffer. Wrap all func calls with 'hact'.
51+
man/hyperbole.texi (Smart Key - Treemacs): Update doc to match above change.
52+
(smart-treemacs-quit): Add to ensure treemacs-quit is run
53+
within the Treemacs window.
54+
55+
* hywiki.el (hywiki-directory-edit): Support non-bash shells that cannot handle
56+
character classes.
57+
158
2024-11-10 Mats Lidell <[email protected]>
259

360
* test/hywiki-tests.el (hywiki-tests--add-hywiki-hooks)
@@ -10,6 +67,21 @@
1067
(hywiki-tests--verify-face-property-when-editing-wikiword-first-char):
1168
Tests using the hook mimicking functions.
1269

70+
2024-11-03 Bob Weiner <[email protected]>
71+
72+
* hywiki.el (hywiki-maybe-highlight-page-name, hywiki-maybe-dehighlight-page-name):
73+
Change to use function (hywiki-get-buttonize-characters) rather than the
74+
variable, hywiki--buttonize-characters, so do not move back over whitespace
75+
when at the beginning of a HyWikiWord.
76+
77+
* hyrolo.el (hyrolo-grep-file): Don't set grepped file to read-only since
78+
this can later make org-capture fail. (gh#rswgnu/hyperbole/599)
79+
80+
2024-11-02 Bob Weiner <[email protected]>
81+
82+
* man/hyperbole.texi: Change all @url to @uref so display properly in
83+
Info-format output.
84+
1385
2024-11-02 Mats Lidell <[email protected]>
1486

1587
* test/hywiki-tests.el (hywiki-tests--word-is-p)
@@ -36,7 +108,7 @@
36108
an infinite loop.
37109
(hywiki-add-page, hywiki-make-pages-hasht): Reset
38110
'hywiki--any-page-regexp-list' whenever hasht is rebuilt. Otherwise,
39-
highlihgting might not include new wikiwords in hasht.
111+
highlighting might not include new wikiwords in hasht.
40112

41113
2024-10-27 Bob Weiner <[email protected]>
42114

hui-jmenu.el

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 9-Mar-94 at 23:37:28
6-
;; Last-Mod: 19-Jan-24 at 14:09:51 by Mats Lidell
6+
;; Last-Mod: 11-Nov-24 at 00:35:43 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -111,7 +111,8 @@
111111

112112
;;;###autoload
113113
(defun hui-menu-screen-commands ()
114-
"Popup a menu of buffers, frames, and windows, allowing user to jump to one."
114+
"Popup a menu of screen control and jump to menus.
115+
Jump to: HyWiki pages, buffers, frames, and windows."
115116
(interactive)
116117
(popup-menu '("Hyperbole Screen Commands" :filter hui-menu-modeline)))
117118

@@ -177,6 +178,8 @@ Jump to chosen buffer."
177178
(defun hui-menu-modeline (_ignore)
178179
"Return a modeline menu."
179180
(list
181+
["HyWiki-Edit-Pages" hywiki-directory-edit t]
182+
"----"
180183
["Control-Frames" hycontrol-enable-frames-mode t]
181184
["Control-Windows" hycontrol-enable-windows-mode t]
182185
"----"

hui-treemacs.el

+52-39
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Nov-17
6-
;; Last-Mod: 20-Jan-24 at 20:20:00 by Mats Lidell
6+
;; Last-Mod: 10-Nov-24 at 17:27:30 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -26,7 +26,8 @@
2626

2727
(or (require 'treemacs nil t)
2828
(and (package-installed-p 'treemacs)
29-
(package-activate 'treemacs)))
29+
(package-activate 'treemacs))
30+
(hypb:require-package 'treemacs))
3031

3132
(defvar treemacs-version)
3233

@@ -39,10 +40,10 @@
3940
(declare-function treemacs "ext:treemacs")
4041
(declare-function treemacs-current-button "ext:treemacs-core-utils")
4142
(declare-function treemacs-current-visibility "ext:treemacs-scope")
42-
(declare-function treemacs-get-local-buffer "ext:treemacs-scope")
43+
(declare-function treemacs-get-local-window "ext:treemacs-scope")
4344
(declare-function treemacs-is-treemacs-window? "ext:treemacs-core-utils")
44-
(declare-function treemacs-node-buffer-and-position "etx:treemacs-mouse-interface")
45-
(declare-function treemacs-quit "ext:treemacs-core-utils")
45+
(declare-function treemacs-node-buffer-and-position "ext:treemacs-mouse-interface")
46+
(declare-function treemacs-quit "ext:treemacs-interface")
4647
(declare-function treemacs-toggle-node "ext:treemacs-interface")
4748
(defvar aw-ignored-buffers)
4849

@@ -68,6 +69,25 @@
6869
(unless (fboundp 'treemacs-quit)
6970
(fset 'treemacs-quit #'bury-buffer))
7071

72+
;;;###autoload
73+
(defun smart-treemacs-edit (&optional dir)
74+
"Use `treemacs' to edit optional DIR or the `default-directory'."
75+
(let ((default-directory (if (stringp dir) dir default-directory)))
76+
(cond ((fboundp #'treemacs-add-and-display-current-project-exclusively)
77+
(treemacs-add-and-display-current-project-exclusively))
78+
;; Older obsoleted function
79+
((fboundp #'treemacs-display-current-project-exclusively)
80+
(treemacs-display-current-project-exclusively))
81+
(t (treemacs)))))
82+
83+
(defun smart-treemacs-quit (&optional arg)
84+
"Quit treemacs visible in current frame with `bury-buffer'.
85+
With a prefix ARG call `treemacs-kill-buffer' instead."
86+
(interactive "P")
87+
(when (eq (treemacs-current-visibility) 'visible)
88+
(with-selected-window (treemacs-get-local-window)
89+
(treemacs-quit arg))))
90+
7191
;;;###autoload
7292
(defun smart-treemacs ()
7393
"Use a single key or mouse key to manipulate directory entries.
@@ -77,37 +97,28 @@ caller has already checked that the key was pressed in an appropriate buffer
7797
and has moved the cursor there.
7898
7999
If key is pressed:
80-
(1) on an entry icon, the treemacs TAB command is run to expand and
81-
collapse the entry;
82-
(2) elsewhere within an entry line, the item is displayed for editing,
83-
normally in another window;
84-
(3) at the end of an entry line: invoke `action-key-eol-function',
85-
typically to scroll up proportionally, if an Action Key press; invoke
86-
`assist-key-eol-function', typically to scroll down proportionally,
87-
if an Asisst Key press;
88-
(4) on the first line of the buffer (other than the end of line),
89-
Dired is run on the current directory of this Treemacs;
90-
(5) at the end of the first or last line of the buffer,
91-
this Treemacs invocation is quit."
100+
(1) on or to the left of an entry icon, run the treemacs TAB command
101+
to expand or collapse the entry;
102+
(2) elsewhere within an entry line, display the item, which may be a
103+
directory, for editing, normally in another window;
104+
(3) at the end of an entry line: if an Action Key press, invoke
105+
`action-key-eol-function', typically to scroll up proportionally;
106+
if an Asisst Key press, invoke `assist-key-eol-function', typically
107+
to scroll down proportionally;
108+
(4) at the end of the first or last line of the buffer, quit this
109+
Treemacs invocation."
92110

93111
(interactive)
94-
(cond ((first-line-p)
95-
(if (eolp)
96-
(treemacs-quit)
97-
(hact 'link-to-directory default-directory)))
98-
((and (last-line-p) (eolp))
99-
(treemacs-quit))
112+
(cond ((and (eolp) (or (first-line-p) (last-line-p)))
113+
(hact 'smart-treemacs-quit))
100114
((eolp)
101-
(funcall (if assist-flag assist-key-eol-function action-key-eol-function)))
102-
(t (let ((over-icon (and (treemacs-current-button)
103-
(= (point) (- (button-start (treemacs-current-button)) 2))))
104-
(result (treemacs-node-buffer-and-position)))
105-
(if (and (not over-icon) result (or (bufferp result) (listp result)))
106-
(if (listp result)
107-
(hact 'link-to-buffer-tmp (seq-elt result 0) (seq-elt result 1))
108-
;; (bufferp result)
109-
(hact 'link-to-buffer-tmp result))
110-
(treemacs-toggle-node current-prefix-arg))))))
115+
(hact 'funcall (if assist-flag assist-key-eol-function action-key-eol-function)))
116+
(t (if (and (treemacs-current-button)
117+
(= (point) (- (button-start (treemacs-current-button)) 2)))
118+
;; Before or on the entry's icon
119+
(hact 'treemacs-TAB-action current-prefix-arg)
120+
;; On the entry, handles dirs, files and tag entries
121+
(hact 'treemacs-RET-action current-prefix-arg)))))
111122

112123
;;;###autoload
113124
(defun smart-treemacs-modeline ()
@@ -123,21 +134,23 @@ Suitable for use as a value of `action-key-modeline-buffer-id-function'."
123134
;; Clicked on Treemacs buffer id
124135
((if action-key-depress-window
125136
(treemacs-is-treemacs-window? action-key-depress-window)
126-
(string-match " Treemacs " (format-mode-line mode-line-format)))
137+
(hact 'string-match " Treemacs " (format-mode-line mode-line-format)))
127138
;; Quit/hide treemacs.
128-
(treemacs-quit))
139+
(hact 'treemacs-quit))
129140
;;
130141
;; Treemacs is visible and displaying the same dir as
131142
;; the default dir of the clicked on modeline.
132143
((and (eq (treemacs-current-visibility) 'visible)
133144
(string-equal (expand-file-name default-directory)
134-
(with-current-buffer (treemacs-get-local-buffer)
135-
default-directory)))
145+
(with-selected-window (treemacs-get-local-window)
146+
(save-excursion
147+
(goto-char (point-min))
148+
default-directory))))
136149
;; Quit/hide treemacs.
137-
(treemacs-quit))
150+
(hact 'smart-treemacs-quit))
138151
;;
139152
;; Otherwise, invoke treemacs on the default dir of the clicked on modeline.
140-
(t (treemacs))))
153+
(t (hact 'smart-treemacs-edit))))
141154

142155
(provide 'hui-treemacs)
143156
;;; hui-treemacs.el ends here

0 commit comments

Comments
 (0)