summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-16 01:25:27 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-16 01:25:27 +0200
commit691f79cba98c58b348a5a5dab17830a735040ce2 (patch)
tree9daa1f7df9120703232e9cc7e0f1058624d13337
parent4bc680ade03598f9c044ba0942e387baba47ca75 (diff)
emacs: Remove the ‘mango-for-each’ macro
-rw-r--r--.config/emacs/config.org51
1 files changed, 17 insertions, 34 deletions
diff --git a/.config/emacs/config.org b/.config/emacs/config.org
index 8558b41..d6819cf 100644
--- a/.config/emacs/config.org
+++ b/.config/emacs/config.org
@@ -178,23 +178,6 @@ grab one from the other.
#+END_SRC
-*** Less-Verbose Mapc
-
-One pattern that I need to do a lot is running a ~dolist~ over a list of items,
-and performing some action for each of them. This could also be done with
-~mapcar~. Since this is such a common task, I should probably make a macro to
-make it just that little bit easier for me:
-
-#+BEGIN_SRC elisp
-
- (defmacro mango-for-each (sequence &rest body)
- "Execute BODY for each element of SEQUENCE. The variable ‘x’ is automatically
- set to the current subject of the iteration."
- (declare (indent defun))
- `(mapc (lambda (x) ,@body) ,sequence))
-
-#+END_SRC
-
** Package Management
For package management I like to use ~straight.el~. Before setting that up
@@ -599,9 +582,9 @@ with a custom function that reads a list of mode-specific indentation settings.
(defun mango-set-indentation-settings ()
"Apply the indentation settings specified by ‘mango-indentation-settings’."
(interactive)
- (mango-for-each mango-indentation-settings
- (let* ((mode (car x))
- (args (cdr x))
+ (cl-dolist (plist mango-indentation-settings)
+ (let* ((mode (car plist))
+ (args (cdr plist))
(width (or (plist-get args :width) (default-value 'tab-width)))
(spaces (or (plist-get args :spaces) (not (default-value 'indent-tabs-mode))))
(extra (plist-get args :extra-vars))
@@ -609,7 +592,7 @@ with a custom function that reads a list of mode-specific indentation settings.
(λ (indent-tabs-mode (when spaces -1))
(setq-local tab-width width
evil-shift-width width)
- (mango-for-each extra (set x width)))))
+ (cl-dolist (var extra) (set var width)))))
(add-hook (mango-mode-to-hook mode) callback 95)
(add-hook (mango-mode-to-hook (mango-mode-to-ts-mode mode)) callback 95))))
@@ -824,8 +807,8 @@ want this /everywhere/.
(show-paren-mode -1)
- (mango-for-each (mapcar #'mango-mode-to-hook mango-highlight-matching-parenthesis-modes)
- (add-hook x #'show-paren-local-mode))
+ (cl-dolist (mode mango-highlight-matching-parenthesis-modes)
+ (add-hook (mango-mode-to-hook mode) #'show-paren-local-mode))
#+END_SRC
@@ -853,10 +836,10 @@ display line numbers in certain modes.
'(org-mode)
"A list of modes for which line numbers shouldn’t be displayed.")
- (mango-for-each (mapcar #'mango-mode-to-hook mango-enable-line-numbers-modes)
- (add-hook x #'display-line-numbers-mode))
- (mango-for-each (mapcar #'mango-mode-to-hook mango-disable-line-numbers-modes)
- (add-hook x (λ (display-line-numbers-mode -1))))
+ (cl-dolist (mode mango-enable-line-numbers-modes)
+ (add-hook (mango-mode-to-hook mode) #'display-line-numbers-mode))
+ (cl-dolist (mode mango-disable-line-numbers-modes)
+ (add-hook (mango-mode-to-hook mode) (λ (display-line-numbers-mode -1))))
#+END_SRC
@@ -1029,9 +1012,9 @@ file with a certain file extension.
(require 'rust-ts-mode)
(require 'yaml-ts-mode)
- (mango-for-each `((,(rx ".rs" eos) . rust-ts-mode)
- (,(rx (or ".yml" ".yaml")) . yaml-ts-mode))
- (add-to-list 'auto-mode-alist x))
+ (cl-dolist (pair `((,(rx ".rs" eos) . rust-ts-mode)
+ (,(rx (or ".yml" ".yaml")) . yaml-ts-mode)))
+ (add-to-list 'auto-mode-alist pair))
#+END_SRC
@@ -1135,10 +1118,10 @@ directories just get created automatically.
t t)
(add-hook 'after-save-hook #'mango--remove-auto-directory-hooks t t)))))
- (mango-for-each #'(find-file
- find-alternate-file
- write-file)
- (advice-add x :around #'mango--auto-create-directories))
+ (cl-dolist (command #'(find-file
+ find-alternate-file
+ write-file))
+ (advice-add command :around #'mango--auto-create-directories))
(defun mango--delete-directories-if-appropriate ()
"Delete parent directories if appropriate. This is a function for