(Emacs/*)~stop using create-toggle-function

This commit is contained in:
2024-04-23 18:18:05 +05:30
parent dd9f321567
commit a01cba5589
4 changed files with 21 additions and 32 deletions

View File

@@ -96,7 +96,7 @@ to the kill ring and bind it to "Y".
:keymaps 'calendar-mode-map
"Y" #'+calendar/copy-date)
(app-leader
"d" #'+calendar/toggle-calendar)
"d" #'calendar)
:config
(defun +calendar/copy-date ()
"Copy date under cursor into kill ring."
@@ -106,12 +106,7 @@ to the kill ring and bind it to "Y".
(let ((date (calendar-cursor-to-date)))
(when date
(setq date (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))
(kill-new (format-time-string "%Y-%m-%d" date))))))
(+oreo/create-toggle-function
+calendar/toggle-calendar
"*Calendar*"
calendar
nil))
(kill-new (format-time-string "%Y-%m-%d" date)))))))
#+end_src
* Mail
Mail is a funny thing; most people use it just for business or
@@ -417,7 +412,7 @@ function to pull up the eshell quickly.
:commands +shell/toggle-eshell
:general
(shell-leader
"t" #'+shell/toggle-eshell)
"t" #'eshell)
:init
(add-hook
'eshell-mode-hook
@@ -432,13 +427,7 @@ function to pull up the eshell quickly.
:keymaps 'eshell-mode-map
"c" (proc (interactive) (eshell/clear)
(recenter))
"k" #'eshell-kill-process)))
:config
(+oreo/create-toggle-function
+shell/toggle-eshell
"*eshell*"
eshell
t))
"k" #'eshell-kill-process))))
#+end_src
** Eshell pretty symbols and display
Pretty symbols and a display record.

View File

@@ -59,9 +59,15 @@ temporary customisation) in the etc folder.
Functions that don't require a packages to work other than Emacs,
which means I can define them early. These are used much later in the
config.
** Toggle buffer
** WAIT Toggle buffer
:PROPERTIES:
:header-args:emacs-lisp: :tangle no
:END:
Like VSCode's toggling feature for just the terminal but now for
any buffer of choice, as long as I can generate it via a command.
2024-04-23: Don't need this anymore due to
~switch-to-buffer-obey-display-actions~.
#+begin_src emacs-lisp
(with-eval-after-load "window"
(defmacro +oreo/create-toggle-function (func-name buf-name
@@ -253,7 +259,6 @@ dark easily, so here's a command to switch between them.
((eq +oreo/theme 'light)
(load-theme 'personal-primary t)
(setq +oreo/theme 'dark)))))
#+end_src
** Font size
Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
@@ -663,6 +668,7 @@ I have no use for standard 'grep'; ~counsel-swiper~ does the same
thing faster and within Emacs lisp. ~rgrep~ is useful though.
#+begin_src emacs-lisp
(use-package grep
:after evil
:straight nil
:display
("^\\*grep.*"

View File

@@ -578,9 +578,13 @@ a whim and not particularly caring for the current window setup.
Thankfully you can change this via the ~display-buffer-alist~ which
matches buffer names with how the window for the buffer should be
displayed. I add a use-package keyword to make ~display-buffer-alist~
records within use-package.
records within a use-package call.
I have no idea whether it's optimal AT ALL, but it works for me.
2024-04-23: Found this option ~switch-to-buffer-obey-display-actions~
which makes manual buffer switches obey the same constraints via
~display-buffer-alist~ as creating the buffer automatically.
#+begin_src emacs-lisp
(use-package window
:straight nil
@@ -593,6 +597,7 @@ I have no idea whether it's optimal AT ALL, but it works for me.
"k" #'previous-buffer
"D" '(+oreo/clean-buffer-list :which-key "Kill most buffers"))
:init
(setq switch-to-buffer-obey-display-actions t)
(with-eval-after-load "use-package-core"
(add-to-list 'use-package-keywords ':display)
(defun use-package-normalize/:display (_name-symbol _keyword args)

View File

@@ -531,17 +531,11 @@ Setup for python shell, including a toggle option
:commands +python/toggle-repl
:general
(shell-leader
"p" #'+shell/python-toggle-repl)
"p" #'run-python)
:display
("\\*Python\\*"
(display-buffer-at-bottom)
(window-height . 0.25))
:config
(+oreo/create-toggle-function
+shell/python-toggle-repl
"*Python*"
run-python
nil))
(window-height . 0.25)))
#+end_src
* YAML
YAML is a data language which is useful for config files.
@@ -642,14 +636,9 @@ development on Emacs.
(setq-default org-babel-lisp-eval-fn #'sly-eval))
(with-eval-after-load "company"
(add-hook 'sly-mrepl-hook #'company-mode))
(+oreo/create-toggle-function
+shell/toggle-sly
"*sly-mrepl for sbcl*"
sly-mrepl
nil)
:general
(shell-leader
"s" #'+shell/toggle-sly)
"s" #'sly-mrepl)
(nmap
:keymaps '(lisp-mode-map sly-mrepl-mode-map)
"gr" #'sly-eval-buffer