-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for moody and doom-modeline. #7
Comments
You have to customize |
The problem with these modeline modifications is they are built with |
Sorry but I don't understand. |
I am using the following modeline: (setq-default mode-line-format '("%e" (:eval (spaceline-ml-main))))
|
It seems unfortunate to me what spaceline is doing. Emacs provides a customization interface "list/tree of of elements stored in variable mode-line-format", which has the advantage that it is easy for packages to add additional elements. Spaceline chooses to ignore that interface as much as it possibly can, which has the drawback that now every package that wants to add an element to the mode-line now has to reimplement that just for spaceline once a users of spaceline comes along. Or not--I don't think I am going to do that. Sorry. However once you have implemented the below mode I might add that to keycast. I might also consider it too ugly and "its not my fault that spaceline makes such ugly hacks necessary" and you might then have to distribute it as a separate package. (define-minor-mode spaceline-keycast-mode
"Show current command and its key binding in the mode line.
This is a reimplementation of `keycast-mode' for use by users
of the `spaceline' package."
:global t
(if spaceline-keycast-mode
(progn
;; ... your code here ...
(add-hook 'pre-command-hook 'keycast-mode-line-update t))
;; ... your code here ...
(remove-hook 'pre-command-hook 'keycast-mode-line-update))) |
FYI, I got it working with the the help of doom-emacs creator through the discord channel: This was the the code that made it work for me: (after! keycast
(define-minor-mode keycast-mode
"Show current command and its key binding in the mode line."
:global t
(if keycast-mode
(add-hook 'pre-command-hook 'keycast--update t)
(remove-hook 'pre-command-hook 'keycast--update))))
(add-to-list 'global-mode-string '("" mode-line-keycast))
(keycast-mode) ;; or run keycast-mode by demand non doom-emacs users: (with-eval-after-load 'keycast
(define-minor-mode keycast-mode
"Show current command and its key binding in the mode line."
:global t
(if keycast-mode
(add-hook 'pre-command-hook 'keycast--update t)
(remove-hook 'pre-command-hook 'keycast--update)))
(add-to-list 'global-mode-string '("" mode-line-keycast))) https://discord.com/channels/406534637242810369/603399769015975996/709874678520610946 edit:
|
These conversations are behind registration walls. Beyond the realization that the |
ohh right, the conversations are not public available as in Github, sorry about that. Honestly, I didn't dig into this too much, he was helping other people at the same time. (after! keycast ;; same as (with-eval-after-load 'keycast
(add-to-list 'global-mode-string '("" mode-line-keycast))) and ended with the one above. |
@d1egoaz Just tried your code, It appear to be working fine using doom-modeline. Thanks for sharing. |
If anyone visiting this page, the command |
updated! thanks |
Thanks Diego Alvarez. tarsius/keycast#7 (comment)
Thanks Diego Alvarez. tarsius/keycast#7 (comment)
So, to summarize, to be able to use doome-modeline with keycast-mode, how to proceed? Thanks! |
|
For those using (use-package keycast
:config
(define-minor-mode keycast-mode
"Show current command and its key binding in the mode line (fix for use with doom-mode-line)."
:global t
(if keycast-mode
(add-hook 'pre-command-hook 'keycast--update t)
(remove-hook 'pre-command-hook 'keycast--update)))
(add-to-list 'global-mode-string '("" mode-line-keycast))) |
@otech-nl Found the same code on EmacsWiki -- when I shut off |
No, sorry. That doesn't sound familiar. |
With the latest change 72d9add, |
Thanks! Is there a way for it to be shown in a pop up? |
For my personal use, I created a "freestyle" mode that doesn't attempt to display anything and just leaves the result in a variable. The existing modeline integration was trying to do a lot. This was easier to integrate (example below). https://github.com/psionic-k/keycast/tree/freestyle-mode I agree with Tarsius that these modeline packages are not playing nice. It's fine to eliminate modeline spam, but advice is almost always a sure sign that something was too rigid. (use-package keycast
:config
(setopt keycast-mode-line-format
"%k%c%r ")
(setopt keycast-substitute-alist
'((keycast-log-erase-buffer nil nil)
(transient-update nil nil)
(self-insert-command nil nil)
(mwheel-scroll nil nil)))
;; Unfortunately "for historical reasons" according to the manual, there is no
;; facility to read the actual `selected-window' when it has been temporarily
;; set. Even if you know what you are doing. Luckily Tarsius has us covered
;; with a workaround in the moody package.
(defvar moody--active-window (selected-window))
(defun moody-window-active-p ()
"Return t if the selected window is the active window.
Or put differently, return t if the possibly only temporarily
selected window is still going to be selected when we return
to the command loop."
(eq (selected-window) moody--active-window))
(defun moody--set-active-window (_)
(let ((win (selected-window)))
(setq moody--active-window
(if (minibuffer-window-active-p win)
(minibuffer-selected-window)
win))))
(add-hook 'pre-redisplay-functions #'moody--set-active-window)
;; Decorating an existing item in the modeline
(defun pmx-keycast-doom-modeline-update (return)
(if (moody-window-active-p)
(concat return " " keycast-last-formatted)
return))
;; Mode line hooks get called on start and stop :-)
(defun pmx-keycast-doom-modeline-integrate ()
(if keycast-freestyle-mode
(advice-add #'doom-modeline-segment--buffer-position :filter-return
#'pmx-keycast-doom-modeline-update)
(advice-remove #'doom-modeline-segment--buffer-position
#'pmx-keycast-doom-modeline-update)))
(add-hook 'keycast-freestyle-mode-hook #'pmx-keycast-doom-modeline-integrate)) |
Using keycast with moody or doom-modeine give the following errors respectively:
Error (use-package): keycast/:config: Cannot turn on keycast-mode. mode-line-buffer-identification not found in mode-line-format
user-error: Cannot turn on keycast-mode. mode-line-buffer-identification not found in mode-line-format
Can it even work with those modelines?
The text was updated successfully, but these errors were encountered: