Skip to content

Commit

Permalink
[fus] normalise lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Nov 12, 2024
1 parent a615a70 commit af171cf
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 100 deletions.
93 changes: 47 additions & 46 deletions modules/init-bde-style.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ switch(val) {
'(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))

;; Allow tab in Makefile
(add-hook 'makefile-mode-hook #'(lambda () (setq indent-tabs-mode t)))

(use-package make-mode
:ensure nil
:hook (makefile-mode . indent-tabs-mode))

;;; Insert class header

Expand Down Expand Up @@ -532,8 +533,8 @@ first `exordium-bde-search-max-bound' characters."
(when from
(save-excursion
(goto-char from)
(let ((any-of-is-car-of #'(lambda (any-of elem-list)
(cl-member (car elem-list) any-of)))
(let ((any-of-is-car-of (lambda (any-of elem-list)
(cl-member (car elem-list) any-of)))
(bound (+ from exordium-bde-search-max-bound))
(candidate nil))
(catch 'pos
Expand Down Expand Up @@ -563,8 +564,8 @@ Bounds are returned a cons (START . END). Opening and closing
parenthesis are included. Return nil when no argument list has
been found."
(let* ((basic-syntax (c-guess-basic-syntax))
(any-of-is-car-of #'(lambda (any-of elem-list)
(cl-member (car elem-list) any-of)))
(any-of-is-car-of (lambda (any-of elem-list)
(cl-member (car elem-list) any-of)))
(start (or
;; most of the `arglist-*' syntactic elements have the buffer
;; location of opening parenthesis as the third (last) value
Expand All @@ -588,16 +589,16 @@ been found."
t)
;; the `arglist-cont' has only the `arglist-intro' position
;; one extra jump is needed before an extraction
(funcall #'(lambda (pos)
(when pos
(save-excursion
(goto-char pos)
(nth 2
(car (cl-member '(arglist-intro
arglist-cont-nonempty
arglist-close)
(c-guess-basic-syntax)
:test any-of-is-car-of))))))
(funcall (lambda (pos)
(when pos
(save-excursion
(goto-char pos)
(nth 2
(car (cl-member '(arglist-intro
arglist-cont-nonempty
arglist-close)
(c-guess-basic-syntax)
:test any-of-is-car-of))))))
(nth 1
(car (cl-member '(arglist-cont)
basic-syntax
Expand Down Expand Up @@ -727,20 +728,20 @@ declaration or definition."
(when args
;; Parse each argument and get the max type length
(setq parsed-args
(mapcar #'(lambda (arg)
(let ((parsed-arg (bde-parse-argument arg)))
(setq max-type-length (max max-type-length
(length (car parsed-arg)))
max-stars (max max-stars
(caddr parsed-arg))
max-var-length (max max-var-length
(- (length (cadr parsed-arg))
(caddr parsed-arg))))
parsed-arg))
(mapcar (lambda (arg)
(let ((parsed-arg (bde-parse-argument arg)))
(setq max-type-length (max max-type-length
(length (car parsed-arg)))
max-stars (max max-stars
(caddr parsed-arg))
max-var-length (max max-var-length
(- (length (cadr parsed-arg))
(caddr parsed-arg))))
parsed-arg))
args))
(funcall #'(lambda (bounds)
(goto-char (car bounds))
(delete-region (car bounds) (cdr bounds)))
(funcall (lambda (bounds)
(goto-char (car bounds))
(delete-region (car bounds) (cdr bounds)))
(bounds-of-thing-at-point 'arglist))
(insert
(with-temp-buffer
Expand Down Expand Up @@ -773,18 +774,18 @@ declaration or definition."
;; Reindent
(save-restriction
(widen)
(funcall #'(lambda (bounds)
(indent-region (car bounds) (cdr bounds)))
(funcall (lambda (bounds)
(indent-region (car bounds) (cdr bounds)))
(bounds-of-thing-at-point 'arglist)))

;; If some lines exceed the dreadful 79th column, insert a new line before
;; the first line and reindent, with longest line to the right edge
(save-excursion
(let* ((bounds (bounds-of-thing-at-point 'arglist))
(start-col 0)
(max-col (funcall #'(lambda (bounds)
(bde-max-column-in-region (car bounds)
(cdr bounds)))
(max-col (funcall (lambda (bounds)
(bde-max-column-in-region (car bounds)
(cdr bounds)))
bounds)))
(when (> max-col 79)
(goto-char (car bounds))
Expand All @@ -793,14 +794,14 @@ declaration or definition."
(newline)
(let ((longest-length (- max-col start-col)))
(if (<= longest-length 79)
(funcall #'(lambda (bounds)
(indent-region (car bounds)
(cdr bounds)
(- 79 longest-length)))
(funcall (lambda (bounds)
(indent-region (car bounds)
(cdr bounds)
(- 79 longest-length)))
(bounds-of-thing-at-point 'arglist))
;; We cannot indent correctly, some lines are too long
(funcall #'(lambda (bounds)
(indent-region (car bounds) (cdr bounds)))
(funcall (lambda (bounds)
(indent-region (car bounds) (cdr bounds)))
(bounds-of-thing-at-point 'arglist))
(message "Longest line is %d chars" longest-length))))))
;; Leave the cursor after the closing parenthese instead of on the opening
Expand Down Expand Up @@ -922,14 +923,14 @@ include semicolons."
;; to the previous element. Also the type must be re-guessed to
;; remove any line starting with //
(let ((type-lines (mapcan #'trim (split-string type "\n"))))
(setq type (mapconcat #'(lambda (s)
(if (string-prefix-p "//" s) "" s))
(setq type (mapconcat (lambda (s)
(if (string-prefix-p "//" s) "" s))
type-lines
"")
comment (mapconcat #'(lambda (s)
(if (string-prefix-p "//" s)
(substring s 2)
""))
comment (mapconcat (lambda (s)
(if (string-prefix-p "//" s)
(substring s 2)
""))
(mapcan #'trim (split-string element "\n"))
""))))
;; Add the comment to the previous element.
Expand Down
12 changes: 6 additions & 6 deletions modules/init-cpp.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
;; same conditions as in init-treesit.el
(version< "29" emacs-version) (treesit-available-p))
(progn
(add-hook 'c-ts-mode-hook #'(lambda () (run-hooks 'c-mode-common-hook)))
(add-hook 'c++-ts-mode-hook #'(lambda () (run-hooks 'c-mode-common-hook)))
(add-hook 'c-ts-mode-hook (lambda () (run-hooks 'c-mode-common-hook)))
(add-hook 'c++-ts-mode-hook (lambda () (run-hooks 'c-mode-common-hook)))
(add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
(add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode))
(add-to-list 'major-mode-remap-alist
Expand Down Expand Up @@ -190,10 +190,10 @@ With argument, switch to the second choice. For example, from a
t)
"\\>")))
(add-hook 'c++-mode-hook
#'(lambda()
;; This can be completed with other things later (C++17?)
(font-lock-add-keywords
nil `((,keywords . font-lock-keyword-face))))
(lambda()
;; This can be completed with other things later (C++17?)
(font-lock-add-keywords
nil `((,keywords . font-lock-keyword-face))))
t)))
(:modern
(use-package modern-cpp-font-lock
Expand Down
4 changes: 2 additions & 2 deletions modules/init-flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ See URL `http://mypy-lang.org/'."
(flycheck-add-next-checker checker '(warning . exordium-python-mypy)))
'(python-flake8 python-pylint python-pycompile))
(add-hook 'python-mode-hook
#'(lambda ()
(add-to-list 'flycheck-disabled-checkers 'python-mypy)))
(lambda ()
(add-to-list 'flycheck-disabled-checkers 'python-mypy)))


;; A custom ruff checker with error explanations
Expand Down
36 changes: 18 additions & 18 deletions modules/init-forge.el
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,24 @@ Each element of TO-DELETE is in the same format as used in
(async-start
;; Deletion can be very slow and could block UI. To be executed in a
;; child process.
`(lambda ()
(package-initialize)
(require 'forge)
,(async-inject-variables "\\`\\(to-delete\\|forge-alist\\)\\'")
(let (results)
(dolist (repo to-delete)
(when-let* ((forge-repo (forge-get-repository (cdr repo))))
(let ((t0 (current-time))
;; Timeout is huge (10x what was the default at the
;; time of writing this) as db ops are long sometimes.
;; And this is happening in a child process anyway.
(emacsql-global-timeout 300))
(closql-delete forge-repo)
(setq results
(cons (append (cdr repo)
(list (float-time (time-since t0))))
results)))))
results))
(lambda ()
(package-initialize)
(require 'forge)
(async-inject-variables "\\`\\(to-delete\\|forge-alist\\)\\'")
(let (results)
(dolist (repo to-delete)
(when-let* ((forge-repo (forge-get-repository (cdr repo))))
(let ((t0 (current-time))
;; Timeout is huge (10x what was the default at the
;; time of writing this) as db ops are long sometimes.
;; And this is happening in a child process anyway.
(emacsql-global-timeout 300))
(closql-delete forge-repo)
(setq results
(cons (append (cdr repo)
(list (float-time (time-since t0))))
results)))))
results))
(lambda (results)
(when results (magit-refresh))
(dolist (repo results)
Expand Down
12 changes: 6 additions & 6 deletions modules/init-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,13 @@ http://stackoverflow.com/questions/9656311/conflict-resolution-with-emacs-ediff-
(defun exordium--add-copy-both-to-ediff-mode-map ()
(when ediff-merge-job
(define-key ediff-mode-map "A"
#'(lambda ()
(interactive)
(exordium-ediff-copy-both-to-C "A" "B")))
(lambda ()
(interactive)
(exordium-ediff-copy-both-to-C "A" "B")))
(define-key ediff-mode-map "B"
#'(lambda ()
(interactive)
(exordium-ediff-copy-both-to-C "B" "A")))))
(lambda ()
(interactive)
(exordium-ediff-copy-both-to-C "B" "A")))))

(defconst exordium--ediff-long-help-message-merge
"
Expand Down
18 changes: 9 additions & 9 deletions modules/init-iwyu.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ The first word (assumed: the compiler) is skipped. The
\\='backslash double quote\\=' sequences of arguments are
returned as single element."
(let* ((quote-match
#'(lambda (list start)
(cl-position-if
'(lambda (x) (string-match "\\\"" x))
list
:start start)))
(lambda (list start)
(cl-position-if
(lambda (x) (string-match "\\\"" x))
list
:start start)))
(args (cdr (split-string command)))
(start (funcall quote-match args 0))
(end (funcall quote-match args
Expand Down Expand Up @@ -118,9 +118,9 @@ Such constructed list then is appended to arguments in
(iwyu-mode)
(substitute-key-definition
'recompile
`(lambda ()
(interactive)
(iwyu-start-process-for ',compile-commands-db ',file))
(lambda ()
(interactive)
(iwyu-start-process-for compile-commands-db file))
(current-local-map)))
(apply
'start-process
Expand All @@ -129,7 +129,7 @@ Such constructed list then is appended to arguments in
"include-what-you-use"
(append
exordium-iwyu-extra-args
(cl-remove-if '(lambda (x) (member x exordium-iwyu-filter-args))
(cl-remove-if (lambda (x) (member x exordium-iwyu-filter-args))
(iwyu-prepare-args (plist-get entry :command)))))
(display-buffer buffer-name)
(other-window 1)
Expand Down
4 changes: 2 additions & 2 deletions modules/init-linum.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
Otherwise return nil."
(or (minibufferp)
(and exordium-inhibit-line-numbers-modes
(cl-find-if #'(lambda (mode)
(derived-mode-p mode))
(cl-find-if (lambda (mode)
(derived-mode-p mode))
exordium-inhibit-line-numbers-modes))
(and exordium-inhibit-line-numbers-star-buffers
(eq 0 (string-match "*" (buffer-name))))
Expand Down
2 changes: 1 addition & 1 deletion modules/init-look-and-feel.el
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Set FONT and SIZE if they are passed as arguments."
;;;(global-visual-line-mode 1)

;; Show only 1 window on startup (useful if you open multiple files)
(add-hook 'emacs-startup-hook #'(lambda () (delete-other-windows)) t)
(add-hook 'emacs-startup-hook #'delete-other-windows t)


;;; Keyboard preferences
Expand Down
6 changes: 3 additions & 3 deletions modules/init-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@

:config
(add-hook 'org-src-mode-hook
#'(lambda ()
(when (boundp 'flycheck-disabled-checkers)
(add-to-list 'flycheck-disabled-checkers 'emacs-lisp-checkdoc))))
(lambda ()
(when (boundp 'flycheck-disabled-checkers)
(add-to-list 'flycheck-disabled-checkers 'emacs-lisp-checkdoc))))

(add-hook 'org-mode-hook #'turn-on-visual-line-mode)

Expand Down
4 changes: 2 additions & 2 deletions modules/init-treesit.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
(hook (intern (concat (symbol-name mode) "-mode-hook")))
((and (symbolp ts-hook) (symbolp hook))))
(add-hook ts-hook
#'(lambda ()
(run-hooks hook)))))
(lambda ()
(run-hooks hook)))))

(if (and (version< "29" emacs-version) (treesit-available-p))
(progn
Expand Down
10 changes: 5 additions & 5 deletions modules/init-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ When called with ARG, do this that many times."
;;; symetrical. C-Left and C-Right are left unchanged (move by words).

(define-key global-map [(meta right)]
#'(lambda (arg)
(lambda (arg)
(interactive "p")
(forward-same-syntax arg)))

(define-key global-map [(meta left)]
#'(lambda (arg)
(interactive "p")
(forward-same-syntax (- arg))))
(lambda (arg)
(interactive "p")
(forward-same-syntax (- arg))))


;;; FCI: 80-column ruler bound to Ctrl-|
Expand Down Expand Up @@ -366,7 +366,7 @@ Use a prefix arg to provide LEN. Plain `C-u' (no number) uses
(defun kill-all-buffers ()
"Kill all buffers that are associated with a file."
(interactive)
(mapc #'(lambda (buff)
(mapc (lambda (buff)
(when (buffer-file-name buff)
(kill-buffer buff)))
(buffer-list)))
Expand Down

0 comments on commit af171cf

Please sign in to comment.