[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-proje
From: |
Juri Linkov |
Subject: |
bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-project errors on non-project commands |
Date: |
Mon, 05 Jun 2023 09:50:44 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>> And indeed with the following patch replacing the current definition of
>> 'project-switch-project' with just:
>>
>> (defun project-switch-project (dir)
>> (interactive (list (funcall project-prompter)))
>> (setq next-default-directory dir))
>
> This would be a new "prefix command", like the `universal-argument`,
> `C-x RET c`, the `ofw-other-window`, vc-edit-next-command,
> `ofw-other-frame` from the `other-frame-window` package, and a few more.
>
> In order for this new prefix to interact correctly with those other
> ones, it should probably use `prefix-command-preserve-state` and it
> would be good to make it show some visual feedback via
> `prefix-command-echo-keystrokes-functions`.
Here is the same function turned into a prefix command,
so it supports both cases:
1. 'C-x p p d' -- keys from project-prefix-map
2. 'C-x p p C-x d' -- global keybindings
```
(defun project-switch-project (dir)
(interactive (list (funcall project-prompter)))
(if (symbolp project-switch-commands)
(let ((default-directory dir))
(call-interactively project-switch-commands))
(let* ((echofun (lambda () "[switch-project]"))
(postfun (lambda () (remove-hook
'prefix-command-echo-keystrokes-functions
echofun))))
(setq next-default-directory dir)
(add-hook 'prefix-command-echo-keystrokes-functions echofun)
(message (project--keymap-prompt))
(prefix-command-update)
(set-transient-map project-prefix-map nil postfun))))
```
If this is conceptually ok, then more customization could be ported
from project--switch-project-command such as project-switch-use-entire-map.
bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-project errors on non-project commands, Spencer Baugh, 2023/06/01