docs(emacs): remove csetq, replace it with setopt
All checks were successful
deploy / build (push) Successful in 5m24s
All checks were successful
deploy / build (push) Successful in 5m24s
This commit is contained in:
parent
4baaaadf02
commit
d9a7e58f1e
@ -350,47 +350,3 @@ on the matter.
|
|||||||
(unless (string= "-" project-name)
|
(unless (string= "-" project-name)
|
||||||
(format (if (buffer-modified-p) " ◉ %s" " ● %s - Emacs") project-name))))))
|
(format (if (buffer-modified-p) " ◉ %s" " ● %s - Emacs") project-name))))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** A better custom variable setter
|
|
||||||
Something people often forget about custom variables in Elisp is they
|
|
||||||
can have a custom setter that will run some code if we set the
|
|
||||||
variable properly with ~customize-set-variable~, so ~setq~ shouldn’t be
|
|
||||||
the user’s choice by default. But repeatedly writing
|
|
||||||
~customize-set-variable~ can get tiring and boring. So why not take the
|
|
||||||
best of both world and create ~csetq~, a ~setq~ that uses
|
|
||||||
~customize-set-variable~ under the hood while it keeps a syntax similar
|
|
||||||
to the one ~setq~ uses?
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(defmacro csetq (&rest forms)
|
|
||||||
"Bind each custom variable FORM to the value of its VAL.
|
|
||||||
|
|
||||||
FORMS is a list of pairs of values [FORM VAL].
|
|
||||||
`customize-set-variable' is called sequentially on each pair
|
|
||||||
contained in FORMS. This means `csetq' has a similar behaviour as
|
|
||||||
`setq': each VAL expression is evaluated sequentially, i.e. the
|
|
||||||
first VAL is evaluated before the second, and so on. This means
|
|
||||||
the value of the first FORM can be used to set the second FORM.
|
|
||||||
|
|
||||||
The return value of `csetq' is the value of the last VAL.
|
|
||||||
|
|
||||||
\(fn [FORM VAL]...)"
|
|
||||||
(declare (debug (&rest sexp form))
|
|
||||||
(indent 1))
|
|
||||||
;; Check if we have an even number of arguments
|
|
||||||
(when (= (mod (length forms) 2) 1)
|
|
||||||
(signal 'wrong-number-of-arguments (list 'csetq (1+ (length forms)))))
|
|
||||||
;; Transform FORMS into a list of pairs (FORM . VALUE)
|
|
||||||
(let (sexps)
|
|
||||||
(while forms
|
|
||||||
(let ((form (pop forms))
|
|
||||||
(value (pop forms)))
|
|
||||||
(push `(customize-set-variable ',form ,value)
|
|
||||||
sexps)))
|
|
||||||
`(progn ,@(nreverse sexps))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
I first got inspired by [[https://oremacs.com/2015/01/17/setting-up-ediff/][this blog article]] (archived article, just in
|
|
||||||
case) but it seems the code snippet no longer works properly, so not
|
|
||||||
only did I have to modify it to make it work with an arbitrary amount
|
|
||||||
of arguments (as long as it’s pairs of variables and their value), but
|
|
||||||
I also had to make the code simply work.
|
|
||||||
|
@ -409,13 +409,13 @@ configuration for the ~mu4e~ package itself.
|
|||||||
<<mu4e-ical-setup>>
|
<<mu4e-ical-setup>>
|
||||||
<<mu4e-ical-init-config>>
|
<<mu4e-ical-init-config>>
|
||||||
|
|
||||||
(csetq mu4e-completing-read-function 'completing-read
|
(setopt mu4e-completing-read-function 'completing-read
|
||||||
mu4e-use-fancy-chars t
|
mu4e-use-fancy-chars t
|
||||||
message-kill-buffer-on-exit t
|
message-kill-buffer-on-exit t
|
||||||
mu4e-org-support nil)
|
mu4e-org-support nil)
|
||||||
(let ((dir (concat (getenv "HOME") "/Downloads/mu4e")))
|
(let ((dir (concat (getenv "HOME") "/Downloads/mu4e")))
|
||||||
(when (file-directory-p dir)
|
(when (file-directory-p dir)
|
||||||
(csetq mu4e-attachment-dir dir)))
|
(setopt mu4e-attachment-dir dir)))
|
||||||
(defmacro mu4e-view-mode--prepare ()
|
(defmacro mu4e-view-mode--prepare ()
|
||||||
`(lambda () (visual-line-mode 1)))
|
`(lambda () (visual-line-mode 1)))
|
||||||
:gfhook ('mu4e-view-mode-hook (mu4e-view-mode--prepare))
|
:gfhook ('mu4e-view-mode-hook (mu4e-view-mode--prepare))
|
||||||
@ -1331,7 +1331,7 @@ dark mode for PDFs.
|
|||||||
"m" 'pdf-view-midnight-minor-mode)
|
"m" 'pdf-view-midnight-minor-mode)
|
||||||
:config
|
:config
|
||||||
(with-eval-after-load 'pdf-view
|
(with-eval-after-load 'pdf-view
|
||||||
(csetq pdf-view-midnight-colors '("#d8dee9" . "#2e3440"))))
|
(setopt pdf-view-midnight-colors '("#d8dee9" . "#2e3440"))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
One thing ~pdf-tools~ doesn’t handle is restoring the PDF to the last
|
One thing ~pdf-tools~ doesn’t handle is restoring the PDF to the last
|
||||||
@ -1365,7 +1365,7 @@ doing and what Git is doing! In short, I absolutely love it!
|
|||||||
:config
|
:config
|
||||||
(add-hook 'magit-process-find-password-functions 'magit-process-password-auth-source)
|
(add-hook 'magit-process-find-password-functions 'magit-process-password-auth-source)
|
||||||
<<magit-angular-keywords-highlight>>
|
<<magit-angular-keywords-highlight>>
|
||||||
(csetq magit-clone-default-directory "~/fromGIT/"
|
(setopt magit-clone-default-directory "~/fromGIT/"
|
||||||
magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
|
magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
|
||||||
(with-eval-after-load 'evil-collection
|
(with-eval-after-load 'evil-collection
|
||||||
(phundrak/evil
|
(phundrak/evil
|
||||||
|
@ -81,7 +81,7 @@ Since Emacs 29, it is possible to enable drag-and-drop between Emacs
|
|||||||
and other applications.
|
and other applications.
|
||||||
#+name: dired-drag-and-drop
|
#+name: dired-drag-and-drop
|
||||||
#+begin_src emacs-lisp :tangle no
|
#+begin_src emacs-lisp :tangle no
|
||||||
(csetq dired-mouse-drag-files t
|
(setopt dired-mouse-drag-files t
|
||||||
mouse-drag-and-drop-region-cross-program t)
|
mouse-drag-and-drop-region-cross-program t)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ In Dirvish, it’s best to use the long name of flags whenever possible,
|
|||||||
otherwise some commands won’t work.
|
otherwise some commands won’t work.
|
||||||
#+name: dired-listing-flags
|
#+name: dired-listing-flags
|
||||||
#+begin_src emacs-lisp :tangle no
|
#+begin_src emacs-lisp :tangle no
|
||||||
(csetq dired-listing-switches (string-join '("--all"
|
(setopt dired-listing-switches (string-join '("--all"
|
||||||
"--human-readable"
|
"--human-readable"
|
||||||
"--time-style=long-iso"
|
"--time-style=long-iso"
|
||||||
"--group-directories-first"
|
"--group-directories-first"
|
||||||
@ -121,7 +121,7 @@ files and images.
|
|||||||
(my/dir (lambda (path &optional dir)
|
(my/dir (lambda (path &optional dir)
|
||||||
(expand-file-name (file-name-as-directory path)
|
(expand-file-name (file-name-as-directory path)
|
||||||
(or dir user-emacs-directory)))))
|
(or dir user-emacs-directory)))))
|
||||||
(csetq image-dired-thumb-size 150
|
(setopt image-dired-thumb-size 150
|
||||||
image-dired-dir (funcall my/dir "dired-img")
|
image-dired-dir (funcall my/dir "dired-img")
|
||||||
image-dired-db-file (funcall my/file "dired-db.el")
|
image-dired-db-file (funcall my/file "dired-db.el")
|
||||||
image-dired-gallery-dir (funcall my/dir "gallery")
|
image-dired-gallery-dir (funcall my/dir "gallery")
|
||||||
@ -461,7 +461,7 @@ supported natively. I will describe them here.
|
|||||||
:straight (tramp :type built-in :build t)
|
:straight (tramp :type built-in :build t)
|
||||||
:config
|
:config
|
||||||
<<tramp-add-yadm>>
|
<<tramp-add-yadm>>
|
||||||
(csetq tramp-ssh-controlmaster-options nil
|
(setopt tramp-ssh-controlmaster-options nil
|
||||||
tramp-verbose 0
|
tramp-verbose 0
|
||||||
tramp-auto-save-directory (locate-user-emacs-file "tramp/")
|
tramp-auto-save-directory (locate-user-emacs-file "tramp/")
|
||||||
tramp-chunksize 2000)
|
tramp-chunksize 2000)
|
||||||
|
@ -25,7 +25,7 @@ it bépo-compatible.
|
|||||||
:defer t
|
:defer t
|
||||||
:straight t
|
:straight t
|
||||||
:config
|
:config
|
||||||
(csetq avy-keys '(?a ?u ?i ?e ?c ?t ?s ?r ?n)
|
(setopt avy-keys '(?a ?u ?i ?e ?c ?t ?s ?r ?n)
|
||||||
avy-dispatch-alist '((?x . avy-action-kill-move)
|
avy-dispatch-alist '((?x . avy-action-kill-move)
|
||||||
(?X . avy-action-kill-stay)
|
(?X . avy-action-kill-stay)
|
||||||
(?T . avy-action-teleport)
|
(?T . avy-action-teleport)
|
||||||
@ -71,7 +71,7 @@ What’s the point of using Emacs if you can’t tell everyone?
|
|||||||
:straight (:built t)
|
:straight (:built t)
|
||||||
:defer t
|
:defer t
|
||||||
:config
|
:config
|
||||||
(csetq elcord-use-major-mode-as-main-icon t
|
(setopt elcord-use-major-mode-as-main-icon t
|
||||||
elcord-refresh-rate 5
|
elcord-refresh-rate 5
|
||||||
elcord-boring-buffers-regexp-list `("^ "
|
elcord-boring-buffers-regexp-list `("^ "
|
||||||
,(rx "*" (+ any) "*")
|
,(rx "*" (+ any) "*")
|
||||||
|
@ -60,7 +60,7 @@ it is.
|
|||||||
:host github
|
:host github
|
||||||
:repo "Phundrak/appwrite.el")
|
:repo "Phundrak/appwrite.el")
|
||||||
:config
|
:config
|
||||||
(csetq appwrite-endpoint "https://appwrite.phundrak.com"
|
(setopt appwrite-endpoint "https://appwrite.phundrak.com"
|
||||||
appwrite-devel t))
|
appwrite-devel t))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -1419,7 +1419,7 @@ languages in the same buffer, mainly HTML, CSS, and JavaScript.
|
|||||||
("\\.djhtml\\'" . web-mode)
|
("\\.djhtml\\'" . web-mode)
|
||||||
("\\.vue\\'" . web-mode))
|
("\\.vue\\'" . web-mode))
|
||||||
:config
|
:config
|
||||||
(csetq web-mode-markup-indent-offset 2
|
(setopt web-mode-markup-indent-offset 2
|
||||||
web-mode-code-indent-offset 2
|
web-mode-code-indent-offset 2
|
||||||
web-mode-css-indent-offset 2
|
web-mode-css-indent-offset 2
|
||||||
web-mode-style-padding 0
|
web-mode-style-padding 0
|
||||||
|
Loading…
Reference in New Issue
Block a user