Change to when-let* and if-let*
This commit is contained in:
@ -40,7 +40,7 @@ from inside a C++-style single-line comment."
|
|||||||
(interactive "*Pi")
|
(interactive "*Pi")
|
||||||
(when (and arg (< (prefix-numeric-value arg) 0))
|
(when (and arg (< (prefix-numeric-value arg) 0))
|
||||||
(user-error "Count cannot be negative"))
|
(user-error "Count cannot be negative"))
|
||||||
(if-let ((bounds (c-comments-bounds-at-point))
|
(if-let* ((bounds (c-comments-bounds-at-point))
|
||||||
((or always-continue (not (nth 7 (syntax-ppss))))))
|
((or always-continue (not (nth 7 (syntax-ppss))))))
|
||||||
(progn
|
(progn
|
||||||
(when (c-comments--need-comment-terminator bounds)
|
(when (c-comments--need-comment-terminator bounds)
|
||||||
|
|||||||
@ -49,7 +49,7 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
|||||||
|
|
||||||
(defun ctp--load-content (candidate buffer)
|
(defun ctp--load-content (candidate buffer)
|
||||||
"Load the documentation for CANDIDATE into BUFFER."
|
"Load the documentation for CANDIDATE into BUFFER."
|
||||||
(when-let ((content (funcall corfu-popupinfo--function candidate)))
|
(when-let* ((content (funcall corfu-popupinfo--function candidate)))
|
||||||
;; A bunch of this comes straight from `corfu-popupinfo--show'
|
;; A bunch of this comes straight from `corfu-popupinfo--show'
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(dolist (var corfu-popupinfo--buffer-parameters)
|
(dolist (var corfu-popupinfo--buffer-parameters)
|
||||||
@ -86,7 +86,7 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
|||||||
(forward-line))))
|
(forward-line))))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(put-text-property (point-min) (point-max) 'face 'corfu-popupinfo)
|
(put-text-property (point-min) (point-max) 'face 'corfu-popupinfo)
|
||||||
(when-let ((m (memq 'corfu-default (alist-get 'default face-remapping-alist))))
|
(when-let* ((m (memq 'corfu-default (alist-get 'default face-remapping-alist))))
|
||||||
(setcar m 'corfu-popupinfo)))
|
(setcar m 'corfu-popupinfo)))
|
||||||
;; We succeeded in loading the data
|
;; We succeeded in loading the data
|
||||||
t))
|
t))
|
||||||
@ -95,11 +95,11 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
|||||||
"Find a good position to open the popon for BUFFER's content.
|
"Find a good position to open the popon for BUFFER's content.
|
||||||
Return a list of the position, the max line length that can be shown, and the
|
Return a list of the position, the max line length that can be shown, and the
|
||||||
max height that can be shown. Each line of BUFFER _MUST_ be the same lenght."
|
max height that can be shown. Each line of BUFFER _MUST_ be the same lenght."
|
||||||
(when-let ((point-posn (posn-at-point))
|
(when-let* ((point-posn (posn-at-point))
|
||||||
(point-x (car (posn-x-y point-posn)))
|
(point-x (car (posn-x-y point-posn)))
|
||||||
(point-y (cdr (posn-x-y point-posn))))
|
(point-y (cdr (posn-x-y point-posn))))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(when-let ((completion-pos (popon-position corfu-terminal--popon))
|
(when-let* ((completion-pos (popon-position corfu-terminal--popon))
|
||||||
(completion-size (popon-size corfu-terminal--popon))
|
(completion-size (popon-size corfu-terminal--popon))
|
||||||
(comp-x (car completion-pos))
|
(comp-x (car completion-pos))
|
||||||
(comp-y (cdr completion-pos))
|
(comp-y (cdr completion-pos))
|
||||||
@ -178,7 +178,7 @@ The content extracted is for a popon of size WIDTH by HEIGHT."
|
|||||||
(cl-destructuring-bind (&optional pos width height)
|
(cl-destructuring-bind (&optional pos width height)
|
||||||
(ctp--popon-position buffer)
|
(ctp--popon-position buffer)
|
||||||
(popon-kill ctp--popon)
|
(popon-kill ctp--popon)
|
||||||
(when-let ((pos)
|
(when-let* ((pos)
|
||||||
(content (ctp--extract-content buffer width height)))
|
(content (ctp--extract-content buffer width height)))
|
||||||
(setq ctp--popon
|
(setq ctp--popon
|
||||||
;; appear behind the auto-complete window, in case something
|
;; appear behind the auto-complete window, in case something
|
||||||
@ -212,7 +212,7 @@ CANDIDATE is the same as for `corfu-popupinfo--show'. As this is meant to be
|
|||||||
|
|
||||||
(defun ctp--move-away-from-eob ()
|
(defun ctp--move-away-from-eob ()
|
||||||
"Ensure the point isn't too close to the end of the buffer."
|
"Ensure the point isn't too close to the end of the buffer."
|
||||||
(if-let ((total-lines (count-lines (point-min) (point-max)))
|
(if-let* ((total-lines (count-lines (point-min) (point-max)))
|
||||||
((> total-lines corfu-popupinfo-max-height))
|
((> total-lines corfu-popupinfo-max-height))
|
||||||
(rem-lines (count-lines (point) (point-max)))
|
(rem-lines (count-lines (point) (point-max)))
|
||||||
((< rem-lines corfu-popupinfo-max-height)))
|
((< rem-lines corfu-popupinfo-max-height)))
|
||||||
|
|||||||
@ -92,7 +92,7 @@ Note that the foreground color will be overridden by the module."
|
|||||||
(defun eshell-starship--module-by (field key)
|
(defun eshell-starship--module-by (field key)
|
||||||
"Lookup a list of modules with a FIELD corresponding to KEY.
|
"Lookup a list of modules with a FIELD corresponding to KEY.
|
||||||
FIELD should be one of the keys in `eshell-starship--modules-by'."
|
FIELD should be one of the keys in `eshell-starship--modules-by'."
|
||||||
(when-let ((table (plist-get eshell-starship--modules-by field)))
|
(when-let* ((table (plist-get eshell-starship--modules-by field)))
|
||||||
(gethash key table)))
|
(gethash key table)))
|
||||||
|
|
||||||
(defvar eshell-starship--extra-module-files ()
|
(defvar eshell-starship--extra-module-files ()
|
||||||
@ -302,7 +302,7 @@ The number is rounded to PLACES before being rendered."
|
|||||||
MODULES can also be a single module."
|
MODULES can also be a single module."
|
||||||
(dolist (module (ensure-list modules))
|
(dolist (module (ensure-list modules))
|
||||||
(when (symbolp module) (setq module (symbol-name module)))
|
(when (symbolp module) (setq module (symbol-name module)))
|
||||||
(when-let ((cur-entry (gethash module eshell-starship--module-cache)))
|
(when-let* ((cur-entry (gethash module eshell-starship--module-cache)))
|
||||||
(setf (car cur-entry) nil))))
|
(setf (car cur-entry) nil))))
|
||||||
|
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ Example:
|
|||||||
(eshell-starship--limit-path-parts
|
(eshell-starship--limit-path-parts
|
||||||
3 (let ((cwd (or (file-remote-p default-directory 'localname)
|
3 (let ((cwd (or (file-remote-p default-directory 'localname)
|
||||||
default-directory)))
|
default-directory)))
|
||||||
(if-let ((worktree (vc-root-dir))
|
(if-let* ((worktree (vc-root-dir))
|
||||||
(parent (file-name-parent-directory worktree)))
|
(parent (file-name-parent-directory worktree)))
|
||||||
(file-relative-name cwd (or (file-remote-p parent 'localname)
|
(file-relative-name cwd (or (file-remote-p parent 'localname)
|
||||||
parent))
|
parent))
|
||||||
@ -507,7 +507,7 @@ For example, a revert. If there is no current operation, return nil."
|
|||||||
;;; Non-git VC module
|
;;; Non-git VC module
|
||||||
(defun eshell-starship--vc-status ()
|
(defun eshell-starship--vc-status ()
|
||||||
"Get vc status for `eshell-starship--prompt-function'."
|
"Get vc status for `eshell-starship--prompt-function'."
|
||||||
(when-let ((backend (vc-responsible-backend default-directory t))
|
(when-let* ((backend (vc-responsible-backend default-directory t))
|
||||||
((not (eq backend 'Git))))
|
((not (eq backend 'Git))))
|
||||||
(downcase (symbol-name backend))))
|
(downcase (symbol-name backend))))
|
||||||
|
|
||||||
@ -672,12 +672,12 @@ This requires pyvenv.el or pyenv-mode to work."
|
|||||||
(and (bound-and-true-p pyvenv-virtual-env-name)
|
(and (bound-and-true-p pyvenv-virtual-env-name)
|
||||||
(format " (%s)" pyvenv-virtual-env-name))
|
(format " (%s)" pyvenv-virtual-env-name))
|
||||||
(and (fboundp 'pyenv-mode-version)
|
(and (fboundp 'pyenv-mode-version)
|
||||||
(when-let ((ver (pyenv-mode-version)))
|
(when-let* ((ver (pyenv-mode-version)))
|
||||||
(format " (%s)" ver)))))
|
(format " (%s)" ver)))))
|
||||||
|
|
||||||
(defun eshell-starship--python-status ()
|
(defun eshell-starship--python-status ()
|
||||||
"Return the prompt string for the python module."
|
"Return the prompt string for the python module."
|
||||||
(when-let
|
(when-let*
|
||||||
((python-exec (or (bound-and-true-p python-interpreter) "python"))
|
((python-exec (or (bound-and-true-p python-interpreter) "python"))
|
||||||
(output (process-lines-ignore-status python-exec "--version"))
|
(output (process-lines-ignore-status python-exec "--version"))
|
||||||
((string-match "^Python \\([0-9.]+\\)" (car output))))
|
((string-match "^Python \\([0-9.]+\\)" (car output))))
|
||||||
@ -834,7 +834,7 @@ That is, if EXT is \"pkg.tar.gz\", this will return
|
|||||||
|
|
||||||
(defun eshell-starship--file-name-extension (name)
|
(defun eshell-starship--file-name-extension (name)
|
||||||
"Return the extension for a file name NAME."
|
"Return the extension for a file name NAME."
|
||||||
(if-let ((start (if (string-prefix-p "." name) 1 0))
|
(if-let* ((start (if (string-prefix-p "." name) 1 0))
|
||||||
(idx (cl-position ?. name :start start :test '=)))
|
(idx (cl-position ?. name :start start :test '=)))
|
||||||
(substring name (1+ idx))
|
(substring name (1+ idx))
|
||||||
""))
|
""))
|
||||||
@ -921,7 +921,7 @@ Also cache the time it took to run it and its output."
|
|||||||
(setq start-time (float-time)
|
(setq start-time (float-time)
|
||||||
result (funcall action)
|
result (funcall action)
|
||||||
end-time (float-time))
|
end-time (float-time))
|
||||||
(when-let ((result)
|
(when-let* ((result)
|
||||||
(output
|
(output
|
||||||
(concat prefix
|
(concat prefix
|
||||||
(eshell-starship--propertize-face
|
(eshell-starship--propertize-face
|
||||||
@ -1163,7 +1163,7 @@ If NO-OUTPUT is non-nil, don't insert the modules previous output."
|
|||||||
:test 'equal)
|
:test 'equal)
|
||||||
(if (eq cur-name t)
|
(if (eq cur-name t)
|
||||||
(setq rest-point (point))
|
(setq rest-point (point))
|
||||||
(when-let ((module (gethash cur-name eshell-starship-modules)))
|
(when-let* ((module (gethash cur-name eshell-starship-modules)))
|
||||||
(eshell-starship--explain-insert-module module)
|
(eshell-starship--explain-insert-module module)
|
||||||
(remhash cur-name rest-modules)))))
|
(remhash cur-name rest-modules)))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
@ -1196,7 +1196,7 @@ If NO-OUTPUT is non-nil, don't insert the modules previous output."
|
|||||||
(insert (heading "There are no disabled modules."))
|
(insert (heading "There are no disabled modules."))
|
||||||
(insert (heading "The following modules are disabled:\n"))
|
(insert (heading "The following modules are disabled:\n"))
|
||||||
(dolist (name eshell-starship-disabled-modules)
|
(dolist (name eshell-starship-disabled-modules)
|
||||||
(when-let ((module (gethash name eshell-starship-modules)))
|
(when-let* ((module (gethash name eshell-starship-modules)))
|
||||||
(eshell-starship--explain-insert-module module t)))
|
(eshell-starship--explain-insert-module module t)))
|
||||||
;; get rid of newline
|
;; get rid of newline
|
||||||
(delete-char -1))))
|
(delete-char -1))))
|
||||||
|
|||||||
@ -349,7 +349,7 @@ The completion table contains just the last component. Therefore, the capf
|
|||||||
should specify the START position of this table to be the first character after
|
should specify the START position of this table to be the first character after
|
||||||
the last slash (/) on the line. If none of that made sense, see the
|
the last slash (/) on the line. If none of that made sense, see the
|
||||||
documentation for `completion-at-point-functions'."
|
documentation for `completion-at-point-functions'."
|
||||||
(if-let ((last-slash (cl-position ?/ current-input :from-end t))
|
(if-let* ((last-slash (cl-position ?/ current-input :from-end t))
|
||||||
(base (file-truename
|
(base (file-truename
|
||||||
(substring current-input 0 (1+ last-slash)))))
|
(substring current-input 0 (1+ last-slash)))))
|
||||||
(let ((default-directory base))
|
(let ((default-directory base))
|
||||||
@ -397,7 +397,7 @@ in it."
|
|||||||
CURRENT-INPUT is the current text of the argument to complete. With DIR-ONLY,
|
CURRENT-INPUT is the current text of the argument to complete. With DIR-ONLY,
|
||||||
only report directory completions."
|
only report directory completions."
|
||||||
(ignore-error file-missing
|
(ignore-error file-missing
|
||||||
(let ((dir (if-let ((last-idx (cl-position ?/ current-input
|
(let ((dir (if-let* ((last-idx (cl-position ?/ current-input
|
||||||
:from-end t)))
|
:from-end t)))
|
||||||
(substring current-input 0 (1+ last-idx))
|
(substring current-input 0 (1+ last-idx))
|
||||||
current-input)))
|
current-input)))
|
||||||
@ -471,7 +471,7 @@ With NO-ABSOLUTE, don't complete absolute file names."
|
|||||||
(let ((,idirs (cl-remove-if-not #'file-directory-p
|
(let ((,idirs (cl-remove-if-not #'file-directory-p
|
||||||
(ensure-list ',evaled-dirs)))
|
(ensure-list ',evaled-dirs)))
|
||||||
(,adirname (file-name-directory (cl-third (nth ,index ,args)))))
|
(,adirname (file-name-directory (cl-third (nth ,index ,args)))))
|
||||||
(if-let ((cache (gethash (cons ,adirname ,dirs)
|
(if-let* ((cache (gethash (cons ,adirname ,dirs)
|
||||||
firejail--relative-to-cache)))
|
firejail--relative-to-cache)))
|
||||||
cache
|
cache
|
||||||
(let (,out)
|
(let (,out)
|
||||||
@ -511,7 +511,7 @@ With NO-ABSOLUTE, don't complete absolute file names."
|
|||||||
(defun firejail--get-all-env-keys ()
|
(defun firejail--get-all-env-keys ()
|
||||||
"Return the name of every current environment variable."
|
"Return the name of every current environment variable."
|
||||||
(mapcar (lambda (elt)
|
(mapcar (lambda (elt)
|
||||||
(if-let ((sep (cl-position ?= elt)))
|
(if-let* ((sep (cl-position ?= elt)))
|
||||||
(substring elt 0 sep)
|
(substring elt 0 sep)
|
||||||
elt))
|
elt))
|
||||||
process-environment))
|
process-environment))
|
||||||
@ -681,7 +681,7 @@ argument character on the current line."
|
|||||||
(let* ((cur-arg (if (firejail--multi-arg-directive-p directive)
|
(let* ((cur-arg (if (firejail--multi-arg-directive-p directive)
|
||||||
(firejail--count-args arg-start (point))
|
(firejail--count-args arg-start (point))
|
||||||
1)))
|
1)))
|
||||||
(when-let ((handler (or (gethash (cons directive nil)
|
(when-let* ((handler (or (gethash (cons directive nil)
|
||||||
firejail-profile--keyword-handlers)
|
firejail-profile--keyword-handlers)
|
||||||
(gethash (cons directive cur-arg)
|
(gethash (cons directive cur-arg)
|
||||||
firejail-profile--keyword-handlers))))
|
firejail-profile--keyword-handlers))))
|
||||||
@ -823,7 +823,7 @@ Return a list of the formatted doc and a summary."
|
|||||||
(defun firejail-eldoc-documentation-function (callback &rest _args)
|
(defun firejail-eldoc-documentation-function (callback &rest _args)
|
||||||
"Call CALLBACK with the documentation of the directive under point."
|
"Call CALLBACK with the documentation of the directive under point."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when-let ((name (firejail--directive-at-point))
|
(when-let* ((name (firejail--directive-at-point))
|
||||||
(doc (firejail--documentation-for name)))
|
(doc (firejail--documentation-for name)))
|
||||||
(cl-destructuring-bind (clean-doc summary)
|
(cl-destructuring-bind (clean-doc summary)
|
||||||
(firejail--format-doc-string-and-get-summary name doc)
|
(firejail--format-doc-string-and-get-summary name doc)
|
||||||
|
|||||||
@ -100,7 +100,7 @@ languages supported by this interpreter."))
|
|||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(unless (> (point) start)
|
(unless (> (point) start)
|
||||||
(goto-char start)))
|
(goto-char start)))
|
||||||
(when-let ((thing (treesit-thing-at-point "_" 'nested)))
|
(when-let* ((thing (treesit-thing-at-point "_" 'nested)))
|
||||||
(inf-cc--remove-trailing-semicolon (treesit-node-text thing)))))
|
(inf-cc--remove-trailing-semicolon (treesit-node-text thing)))))
|
||||||
|
|
||||||
(defun inf-cc--java-ts-exp-at-point ()
|
(defun inf-cc--java-ts-exp-at-point ()
|
||||||
@ -215,7 +215,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
|
|
||||||
(defun inf-cc--fontify-current-input ()
|
(defun inf-cc--fontify-current-input ()
|
||||||
"Function called from `post-command-hook' to fontify the current input."
|
"Function called from `post-command-hook' to fontify the current input."
|
||||||
(when-let (((inf-cc-font-lock-mode inf-cc--obj))
|
(when-let* (((inf-cc-font-lock-mode inf-cc--obj))
|
||||||
(proc (get-buffer-process (current-buffer)))
|
(proc (get-buffer-process (current-buffer)))
|
||||||
(start (process-mark proc))
|
(start (process-mark proc))
|
||||||
(end (point-max))
|
(end (point-max))
|
||||||
@ -232,7 +232,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
(let* ((props (text-properties-at i fontified))
|
(let* ((props (text-properties-at i fontified))
|
||||||
(change-i (or (next-property-change i fontified)
|
(change-i (or (next-property-change i fontified)
|
||||||
len)))
|
len)))
|
||||||
(when-let ((face (plist-get props 'face)))
|
(when-let* ((face (plist-get props 'face)))
|
||||||
(setf (plist-get props 'face) nil
|
(setf (plist-get props 'face) nil
|
||||||
(plist-get props 'font-lock-face) face))
|
(plist-get props 'font-lock-face) face))
|
||||||
(set-text-properties (+ start i) (+ start change-i) props)
|
(set-text-properties (+ start i) (+ start change-i) props)
|
||||||
@ -328,7 +328,7 @@ You MUST set `inf-cc--obj' before activating this major mode."
|
|||||||
indent-line-function #'inf-cc--indent-line-function
|
indent-line-function #'inf-cc--indent-line-function
|
||||||
electric-indent-chars '(?\n ?})
|
electric-indent-chars '(?\n ?})
|
||||||
mode-name (concat "Inferior " (upcase-initials name)))
|
mode-name (concat "Inferior " (upcase-initials name)))
|
||||||
(when-let ((font-lock-mode)
|
(when-let* ((font-lock-mode)
|
||||||
(sym (intern-soft (format "%s-syntax-table" font-lock-mode)))
|
(sym (intern-soft (format "%s-syntax-table" font-lock-mode)))
|
||||||
(syntax-table (symbol-value sym)))
|
(syntax-table (symbol-value sym)))
|
||||||
(set-syntax-table syntax-table)))
|
(set-syntax-table syntax-table)))
|
||||||
|
|||||||
@ -36,7 +36,7 @@ This exists so that Emacs doesn't slow down while running
|
|||||||
|
|
||||||
(defun khard--prompt-contact (&optional prompt)
|
(defun khard--prompt-contact (&optional prompt)
|
||||||
"Prompt user for a contact, optionally make the prompt text PROMPT."
|
"Prompt user for a contact, optionally make the prompt text PROMPT."
|
||||||
(if-let ((uid-list (khard--build-uid-email-phone-list))
|
(if-let* ((uid-list (khard--build-uid-email-phone-list))
|
||||||
(resp (completing-read (or prompt "Contact ") uid-list)))
|
(resp (completing-read (or prompt "Contact ") uid-list)))
|
||||||
(assoc resp uid-list)))
|
(assoc resp uid-list)))
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ When called interactively, prompt the user."
|
|||||||
|
|
||||||
(defun khard--parse-email-list (list-str)
|
(defun khard--parse-email-list (list-str)
|
||||||
"Parse LIST-STR, a python dictionary and array string of emails."
|
"Parse LIST-STR, a python dictionary and array string of emails."
|
||||||
(if-let ((length (length list-str))
|
(if-let* ((length (length list-str))
|
||||||
((>= length 2))
|
((>= length 2))
|
||||||
(no-braces (substring list-str 1 -1)))
|
(no-braces (substring list-str 1 -1)))
|
||||||
(let ((output nil)
|
(let ((output nil)
|
||||||
@ -167,8 +167,8 @@ With FORCE, rebuild the cache no matter what."
|
|||||||
(defun khard-insert-email-contact ()
|
(defun khard-insert-email-contact ()
|
||||||
"Use `completing-read' to prompt for and insert a khard contact."
|
"Use `completing-read' to prompt for and insert a khard contact."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if-let (contact (completing-read "Insert Contact "
|
(if-let* ((contact (completing-read "Insert Contact "
|
||||||
(khard--contacts-cache t)))
|
(khard--contacts-cache t))))
|
||||||
(insert contact)))
|
(insert contact)))
|
||||||
|
|
||||||
(defun khard--message-in-header-p (name &optional testfn)
|
(defun khard--message-in-header-p (name &optional testfn)
|
||||||
@ -185,7 +185,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
|
|||||||
(defun khard-message-mode-capf ()
|
(defun khard-message-mode-capf ()
|
||||||
"Completion at point function for khard contacts in message mode."
|
"Completion at point function for khard contacts in message mode."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when-let ((field-start (khard--message-in-header-p "To")))
|
(when-let* ((field-start (khard--message-in-header-p "To")))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((end (point)))
|
(let ((end (point)))
|
||||||
(re-search-backward (rx (any "\n" "," ":") (* whitespace))
|
(re-search-backward (rx (any "\n" "," ":") (* whitespace))
|
||||||
|
|||||||
@ -185,7 +185,7 @@ return t. Otherwise, kill the buffer and return nil."
|
|||||||
(kill-buffer (current-buffer))
|
(kill-buffer (current-buffer))
|
||||||
(user-error "File \"%s\" is binary" file)))
|
(user-error "File \"%s\" is binary" file)))
|
||||||
;; we are good to go
|
;; we are good to go
|
||||||
(when-let (old-buffer (get-buffer latex-help-texdoc-buffer-name))
|
(when-let* ((old-buffer (get-buffer latex-help-texdoc-buffer-name)))
|
||||||
(kill-buffer old-buffer))
|
(kill-buffer old-buffer))
|
||||||
(rename-buffer latex-help-texdoc-buffer-name)
|
(rename-buffer latex-help-texdoc-buffer-name)
|
||||||
(pop-to-buffer (current-buffer))))))
|
(pop-to-buffer (current-buffer))))))
|
||||||
@ -337,7 +337,7 @@ This returns a list of conses of the display name of the entry and the file it
|
|||||||
belongs to. The first item the the returned list is the default value when
|
belongs to. The first item the the returned list is the default value when
|
||||||
prompting with `completing-read'."
|
prompting with `completing-read'."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(when-let ((exit-code (call-process latex-help-texdoc-program nil t
|
(when-let* ((exit-code (call-process latex-help-texdoc-program nil t
|
||||||
nil "-Ml" entry))
|
nil "-Ml" entry))
|
||||||
((not (zerop exit-code))))
|
((not (zerop exit-code))))
|
||||||
;; try to get the programs output without the normal Emacs process
|
;; try to get the programs output without the normal Emacs process
|
||||||
@ -427,11 +427,11 @@ This is done by parsing the index for `latex-help-info-manual'."
|
|||||||
(*? any) ":" (+ " ")
|
(*? any) ":" (+ " ")
|
||||||
(group (+? any)) ".")))))
|
(group (+? any)) ".")))))
|
||||||
(push (list "(SPACE)" "\\(SPACE)") found)
|
(push (list "(SPACE)" "\\(SPACE)") found)
|
||||||
(when-let (entry (assoc "(...\\)" found))
|
(when-let* ((entry (assoc "(...\\)" found)))
|
||||||
(setq found (assoc-delete-all "(...\\)" found))
|
(setq found (assoc-delete-all "(...\\)" found))
|
||||||
(push (cons "(" (cdr entry)) found)
|
(push (cons "(" (cdr entry)) found)
|
||||||
(push (cons ")" (cdr entry)) found))
|
(push (cons ")" (cdr entry)) found))
|
||||||
(when-let (entry (assoc "[...\\]" found))
|
(when-let* ((entry (assoc "[...\\]" found)))
|
||||||
(setq found (assoc-delete-all "[...\\]" found))
|
(setq found (assoc-delete-all "[...\\]" found))
|
||||||
(push (cons "[" (cdr entry)) found)
|
(push (cons "[" (cdr entry)) found)
|
||||||
(push (cons "]" (cdr entry)) found))
|
(push (cons "]" (cdr entry)) found))
|
||||||
@ -497,7 +497,7 @@ they want to use.
|
|||||||
|
|
||||||
If DEFAULT is non-nil, use that instead of prompting. If it does not exist,
|
If DEFAULT is non-nil, use that instead of prompting. If it does not exist,
|
||||||
return nil."
|
return nil."
|
||||||
(when-let (entries (cdr (assoc name (latex-help--get-cache-for-type type))))
|
(when-let* ((entries (cdr (assoc name (latex-help--get-cache-for-type type)))))
|
||||||
(cond
|
(cond
|
||||||
(default
|
(default
|
||||||
(assoc default entries))
|
(assoc default entries))
|
||||||
@ -531,7 +531,7 @@ This returns the name of the thing that was prompted."
|
|||||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||||
which to use. If NODE is non-nil, use that instead."
|
which to use. If NODE is non-nil, use that instead."
|
||||||
(interactive (list (latex-help--prompt-for 'command)))
|
(interactive (list (latex-help--prompt-for 'command)))
|
||||||
(when-let (entry (latex-help--maybe-prompt-entry name 'command node))
|
(when-let* ((entry (latex-help--maybe-prompt-entry name 'command node)))
|
||||||
(latex-help--info-goto-entry entry)))
|
(latex-help--info-goto-entry entry)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@ -540,7 +540,7 @@ which to use. If NODE is non-nil, use that instead."
|
|||||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||||
which to use. If NODE is non-nil, use that instead."
|
which to use. If NODE is non-nil, use that instead."
|
||||||
(interactive (list (latex-help--prompt-for 'environment)))
|
(interactive (list (latex-help--prompt-for 'environment)))
|
||||||
(when-let (entry (latex-help--maybe-prompt-entry name 'environment node))
|
(when-let* ((entry (latex-help--maybe-prompt-entry name 'environment node)))
|
||||||
(latex-help--info-goto-entry entry)))
|
(latex-help--info-goto-entry entry)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@ -549,7 +549,7 @@ which to use. If NODE is non-nil, use that instead."
|
|||||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||||
which to use. If NODE is non-nil, use that instead."
|
which to use. If NODE is non-nil, use that instead."
|
||||||
(interactive (list (latex-help--prompt-for 'package)))
|
(interactive (list (latex-help--prompt-for 'package)))
|
||||||
(when-let (entry (latex-help--maybe-prompt-entry name 'package node))
|
(when-let* ((entry (latex-help--maybe-prompt-entry name 'package node)))
|
||||||
(latex-help--info-goto-entry entry)))
|
(latex-help--info-goto-entry entry)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@ -558,7 +558,7 @@ which to use. If NODE is non-nil, use that instead."
|
|||||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||||
which to use. If NODE is non-nil, use that instead."
|
which to use. If NODE is non-nil, use that instead."
|
||||||
(interactive (list (latex-help--prompt-for 'class)))
|
(interactive (list (latex-help--prompt-for 'class)))
|
||||||
(when-let (entry (latex-help--maybe-prompt-entry name 'class node))
|
(when-let* ((entry (latex-help--maybe-prompt-entry name 'class node)))
|
||||||
(latex-help--info-goto-entry entry)))
|
(latex-help--info-goto-entry entry)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@ -567,7 +567,7 @@ which to use. If NODE is non-nil, use that instead."
|
|||||||
When used interactively, prompt for NAME."
|
When used interactively, prompt for NAME."
|
||||||
(interactive (list (latex-help--prompt-texdoc-entry)))
|
(interactive (list (latex-help--prompt-texdoc-entry)))
|
||||||
(latex-help--maybe-init-caches)
|
(latex-help--maybe-init-caches)
|
||||||
(when-let ((file (latex-help--texdoc-prompt-for-entry-file name)))
|
(when-let* ((file (latex-help--texdoc-prompt-for-entry-file name)))
|
||||||
(latex-help--texdoc-open-file file)))
|
(latex-help--texdoc-open-file file)))
|
||||||
|
|
||||||
(defun latex-help--prompt-info-and-texdoc (info-entry texdoc-entry)
|
(defun latex-help--prompt-info-and-texdoc (info-entry texdoc-entry)
|
||||||
@ -604,7 +604,7 @@ point. If that thing at point is valid, it will open an info buffer to the
|
|||||||
documentation for that thing."
|
documentation for that thing."
|
||||||
(interactive)
|
(interactive)
|
||||||
(latex-help--maybe-init-caches)
|
(latex-help--maybe-init-caches)
|
||||||
(if-let (thing (latex-help--get-thing-at-point))
|
(if-let* ((thing (latex-help--get-thing-at-point)))
|
||||||
(let ((info-entry (assoc (car thing) (latex-help--get-cache-for-type
|
(let ((info-entry (assoc (car thing) (latex-help--get-cache-for-type
|
||||||
(cdr thing))))
|
(cdr thing))))
|
||||||
(texdoc-entry (and (member (cdr thing) '(class package environment))
|
(texdoc-entry (and (member (cdr thing) '(class package environment))
|
||||||
@ -658,7 +658,7 @@ Prompt the user for an info topic or texdoc file, then open that thing."
|
|||||||
(equal entry (car tap)))
|
(equal entry (car tap)))
|
||||||
(setq def-entry (car prompts)
|
(setq def-entry (car prompts)
|
||||||
def-name entry)))
|
def-name entry)))
|
||||||
(when-let ((ans (completing-read (format "LaTeX Help%s: "
|
(when-let* ((ans (completing-read (format "LaTeX Help%s: "
|
||||||
(if def-name
|
(if def-name
|
||||||
(format " (default %s)"
|
(format " (default %s)"
|
||||||
def-name)
|
def-name)
|
||||||
@ -672,7 +672,7 @@ Prompt the user for an info topic or texdoc file, then open that thing."
|
|||||||
(string-match (rx "(Info) " (group (+ (not " ")))
|
(string-match (rx "(Info) " (group (+ (not " ")))
|
||||||
" - " (group (+ any)))
|
" - " (group (+ any)))
|
||||||
ans)
|
ans)
|
||||||
(when-let ((thing (match-string 2 ans))
|
(when-let* ((thing (match-string 2 ans))
|
||||||
(type (intern (downcase (match-string 1 ans))))
|
(type (intern (downcase (match-string 1 ans))))
|
||||||
(entry (latex-help--maybe-prompt-entry thing type)))
|
(entry (latex-help--maybe-prompt-entry thing type)))
|
||||||
(latex-help--info-goto-entry entry)))))))
|
(latex-help--info-goto-entry entry)))))))
|
||||||
|
|||||||
@ -264,7 +264,7 @@ SERVER is the server from which to get the rules."
|
|||||||
"Setup up SERVER for the first time."
|
"Setup up SERVER for the first time."
|
||||||
;; make sure that dir local stuff is picked up
|
;; make sure that dir local stuff is picked up
|
||||||
(save-current-buffer
|
(save-current-buffer
|
||||||
(when-let ((buf (cl-first (eglot--managed-buffers server))))
|
(when-let* ((buf (cl-first (eglot--managed-buffers server))))
|
||||||
(set-buffer buf))
|
(set-buffer buf))
|
||||||
(setf
|
(setf
|
||||||
;; merger of global values is mediated elsewhere
|
;; merger of global values is mediated elsewhere
|
||||||
@ -392,7 +392,7 @@ language setting in any file."
|
|||||||
current-prefix-arg))
|
current-prefix-arg))
|
||||||
(unless (ltex-eglot-server-p server)
|
(unless (ltex-eglot-server-p server)
|
||||||
(user-error "Current server is not an LTeX server!"))
|
(user-error "Current server is not an LTeX server!"))
|
||||||
(when-let ((server (eglot-current-server)))
|
(when-let* ((server (eglot-current-server)))
|
||||||
(setf (ltex-eglot-server--language server) language)
|
(setf (ltex-eglot-server--language server) language)
|
||||||
(let ((ltex-eglot-variable-save-method
|
(let ((ltex-eglot-variable-save-method
|
||||||
(and (not no-save)
|
(and (not no-save)
|
||||||
|
|||||||
@ -74,7 +74,7 @@ about this change."
|
|||||||
|
|
||||||
(defun org-mu4e--pretty-print-fontify-html-part ()
|
(defun org-mu4e--pretty-print-fontify-html-part ()
|
||||||
"Pretty print and fontify the HTML part of the current buffer."
|
"Pretty print and fontify the HTML part of the current buffer."
|
||||||
(when-let ((bounds (org-mu4e--bounds-of-mime-part "text/html"))
|
(when-let* ((bounds (org-mu4e--bounds-of-mime-part "text/html"))
|
||||||
(real-buf (current-buffer)))
|
(real-buf (current-buffer)))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((content
|
(let ((content
|
||||||
@ -145,7 +145,7 @@ Return the newly created buffer."
|
|||||||
(default-directory org-preview-latex-image-directory)
|
(default-directory org-preview-latex-image-directory)
|
||||||
(org-html-postamble nil))
|
(org-html-postamble nil))
|
||||||
(narrow-to-region start (point-max))
|
(narrow-to-region start (point-max))
|
||||||
(if-let ((export-data (org-export-as
|
(if-let* ((export-data (org-export-as
|
||||||
'html nil t nil
|
'html nil t nil
|
||||||
org-mime-export-options)))
|
org-mime-export-options)))
|
||||||
(progn
|
(progn
|
||||||
|
|||||||
62
init.el
62
init.el
@ -508,7 +508,7 @@ directory. Otherwise, run `find-file' on that file."
|
|||||||
(unless name
|
(unless name
|
||||||
(error "No bookmark specified"))
|
(error "No bookmark specified"))
|
||||||
(bookmark-maybe-historicize-string name)
|
(bookmark-maybe-historicize-string name)
|
||||||
(when-let ((file (bookmark-get-filename name)))
|
(when-let* ((file (bookmark-get-filename name)))
|
||||||
(if (file-directory-p file)
|
(if (file-directory-p file)
|
||||||
(let ((default-directory (file-name-as-directory file)))
|
(let ((default-directory (file-name-as-directory file)))
|
||||||
(call-interactively 'find-file))
|
(call-interactively 'find-file))
|
||||||
@ -931,7 +931,7 @@ environment variable accordingly."
|
|||||||
(xdg-runtime-dir) nil nil 'nosort)
|
(xdg-runtime-dir) nil nil 'nosort)
|
||||||
(cdr found))
|
(cdr found))
|
||||||
(cl-destructuring-bind (name . attrs) entry
|
(cl-destructuring-bind (name . attrs) entry
|
||||||
(when-let (((string-match (rx bos "wayland-" (group (+ (any "0-9"))) eos)
|
(when-let* (((string-match (rx bos "wayland-" (group (+ (any "0-9"))) eos)
|
||||||
name))
|
name))
|
||||||
(id (string-to-number (match-string 1 name)))
|
(id (string-to-number (match-string 1 name)))
|
||||||
((or (not (car found)) (< id (car found))))
|
((or (not (car found)) (< id (car found))))
|
||||||
@ -1077,7 +1077,7 @@ visual states."
|
|||||||
"R" 'repunctuate-sentences)
|
"R" 'repunctuate-sentences)
|
||||||
(defun my/embark-target-string ()
|
(defun my/embark-target-string ()
|
||||||
"Target the string at point."
|
"Target the string at point."
|
||||||
(if-let (((not (eobp))) ; prevent next line from causing errors
|
(if-let* (((not (eobp))) ; prevent next line from causing errors
|
||||||
(bounds (bounds-of-thing-at-point 'string)))
|
(bounds (bounds-of-thing-at-point 'string)))
|
||||||
(append (list 'string (buffer-substring-no-properties (car bounds)
|
(append (list 'string (buffer-substring-no-properties (car bounds)
|
||||||
(cdr bounds)))
|
(cdr bounds)))
|
||||||
@ -1184,7 +1184,7 @@ visual states."
|
|||||||
(let ((help-buf (my/help-buffer-exists-p)))
|
(let ((help-buf (my/help-buffer-exists-p)))
|
||||||
(prog1
|
(prog1
|
||||||
(apply oldfun args)
|
(apply oldfun args)
|
||||||
(when-let (((not help-buf))
|
(when-let* (((not help-buf))
|
||||||
(buf (help-buffer)))
|
(buf (help-buffer)))
|
||||||
;; Ensure that, even if `help-buffer' returns nil in the future, we
|
;; Ensure that, even if `help-buffer' returns nil in the future, we
|
||||||
;; don't kill the current buffer
|
;; don't kill the current buffer
|
||||||
@ -1295,7 +1295,7 @@ If BUFFER is nil, the current buffer is used."
|
|||||||
"Show the diagnostics under point."
|
"Show the diagnostics under point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((message))
|
(let ((message))
|
||||||
(when-let (((bound-and-true-p flymake-mode))
|
(when-let* (((bound-and-true-p flymake-mode))
|
||||||
(diag (get-char-property (point) 'flymake-diagnostic)))
|
(diag (get-char-property (point) 'flymake-diagnostic)))
|
||||||
(cl-callf nconc message (string-split (flymake--diag-text diag) "\n" t)))
|
(cl-callf nconc message (string-split (flymake--diag-text diag) "\n" t)))
|
||||||
(when (bound-and-true-p flycheck-mode)
|
(when (bound-and-true-p flycheck-mode)
|
||||||
@ -1307,7 +1307,7 @@ If BUFFER is nil, the current buffer is used."
|
|||||||
(plist-get note :message))
|
(plist-get note :message))
|
||||||
(my/sly-notes-at-point))))
|
(my/sly-notes-at-point))))
|
||||||
;; jinx
|
;; jinx
|
||||||
(when-let (((bound-and-true-p jinx-mode))
|
(when-let* (((bound-and-true-p jinx-mode))
|
||||||
(jinx-msg (jinx--get-overlays (point) (1+ (point)))))
|
(jinx-msg (jinx--get-overlays (point) (1+ (point)))))
|
||||||
(push "misspelled word" message))
|
(push "misspelled word" message))
|
||||||
(when message
|
(when message
|
||||||
@ -1348,7 +1348,7 @@ With PROJECT, return the candiadeets for that project."
|
|||||||
(prog1
|
(prog1
|
||||||
(seq-uniq
|
(seq-uniq
|
||||||
(append
|
(append
|
||||||
(when-let (((bound-and-true-p flymake-mode))
|
(when-let* (((bound-and-true-p flymake-mode))
|
||||||
(diags (if project (flymake--project-diagnostics
|
(diags (if project (flymake--project-diagnostics
|
||||||
project)
|
project)
|
||||||
(flymake-diagnostics))))
|
(flymake-diagnostics))))
|
||||||
@ -1432,14 +1432,14 @@ With PROJECT, give diagnostics for all buffers in the current project."
|
|||||||
(defun my/eglot-documentation-at-point ()
|
(defun my/eglot-documentation-at-point ()
|
||||||
"Show documentation for a symbol at point."
|
"Show documentation for a symbol at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if-let (server (eglot-current-server))
|
(if-let* ((server (eglot-current-server)))
|
||||||
(progn
|
(progn
|
||||||
(unless (buffer-live-p my/-eglot-documentation-buffer)
|
(unless (buffer-live-p my/-eglot-documentation-buffer)
|
||||||
(setq my/-eglot-documentation-buffer
|
(setq my/-eglot-documentation-buffer
|
||||||
(get-buffer-create "*eglot documentation*")))
|
(get-buffer-create "*eglot documentation*")))
|
||||||
(eglot-hover-eldoc-function
|
(eglot-hover-eldoc-function
|
||||||
(lambda (info _ _)
|
(lambda (info _ _)
|
||||||
(if-let (((not (seq-empty-p info)))
|
(if-let* (((not (seq-empty-p info)))
|
||||||
(buff (current-buffer)))
|
(buff (current-buffer)))
|
||||||
(with-current-buffer my/-eglot-documentation-buffer
|
(with-current-buffer my/-eglot-documentation-buffer
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
@ -1645,7 +1645,7 @@ With PROJECT, give diagnostics for all buffers in the current project."
|
|||||||
(defun my/project-eshell (prompt &optional arg)
|
(defun my/project-eshell (prompt &optional arg)
|
||||||
"Switch to or create an eshell buffer in the current projects root."
|
"Switch to or create an eshell buffer in the current projects root."
|
||||||
(interactive (list t current-prefix-arg))
|
(interactive (list t current-prefix-arg))
|
||||||
(if-let ((proj (project-current prompt))
|
(if-let* ((proj (project-current prompt))
|
||||||
(default-directory (project-root proj))
|
(default-directory (project-root proj))
|
||||||
(eshell-buffer-name
|
(eshell-buffer-name
|
||||||
(concat "*eshell for project " default-directory "*")))
|
(concat "*eshell for project " default-directory "*")))
|
||||||
@ -1713,7 +1713,7 @@ COMMAND and COMINT are like `compile'."
|
|||||||
(setq my/project-run-command command))))
|
(setq my/project-run-command command))))
|
||||||
:config
|
:config
|
||||||
(defun my/project-try-dotfile (dir)
|
(defun my/project-try-dotfile (dir)
|
||||||
(if-let (root (locate-dominating-file dir my/project-root-marker))
|
(if-let* ((root (locate-dominating-file dir my/project-root-marker)))
|
||||||
(list 'vc nil root)))
|
(list 'vc nil root)))
|
||||||
(add-hook 'project-find-functions #'my/project-try-dotfile)
|
(add-hook 'project-find-functions #'my/project-try-dotfile)
|
||||||
;; `project-try-vc' causes consult file previews to break!
|
;; `project-try-vc' causes consult file previews to break!
|
||||||
@ -2120,7 +2120,7 @@ This is :around advice, so OLDFUN is the real function
|
|||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((start (point)))
|
(let ((start (point)))
|
||||||
(beginning-of-defun)
|
(beginning-of-defun)
|
||||||
(when-let ((sexp (nth 1 (parse-partial-sexp (point) start))))
|
(when-let* ((sexp (nth 1 (parse-partial-sexp (point) start))))
|
||||||
(goto-char sexp)
|
(goto-char sexp)
|
||||||
(looking-at (rx "(" (* (syntax whitespace)) ":"))))))
|
(looking-at (rx "(" (* (syntax whitespace)) ":"))))))
|
||||||
|
|
||||||
@ -2169,7 +2169,7 @@ line in the block and manually deal with indentation."
|
|||||||
(when (= (pos-bol) (pos-eol))
|
(when (= (pos-bol) (pos-eol))
|
||||||
(beginning-of-line 2))
|
(beginning-of-line 2))
|
||||||
(<= (count-lines (match-beginning 0) (pos-eol))
|
(<= (count-lines (match-beginning 0) (pos-eol))
|
||||||
(if-let ((match (match-string 1)))
|
(if-let* ((match (match-string 1)))
|
||||||
(string-to-number match)
|
(string-to-number match)
|
||||||
1))))
|
1))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
@ -2250,7 +2250,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
(defun my/-sly-fontify-current-input ()
|
(defun my/-sly-fontify-current-input ()
|
||||||
"Function called from `post-command-hook' to fontify the current input."
|
"Function called from `post-command-hook' to fontify the current input."
|
||||||
(let ((deactivate-mark nil))
|
(let ((deactivate-mark nil))
|
||||||
(when-let ((proc (get-buffer-process (current-buffer)))
|
(when-let* ((proc (get-buffer-process (current-buffer)))
|
||||||
(start (process-mark proc))
|
(start (process-mark proc))
|
||||||
(end (point-max))
|
(end (point-max))
|
||||||
(input (buffer-substring-no-properties start end))
|
(input (buffer-substring-no-properties start end))
|
||||||
@ -2266,7 +2266,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
(let* ((props (text-properties-at i fontified))
|
(let* ((props (text-properties-at i fontified))
|
||||||
(change-i (or (next-property-change i fontified)
|
(change-i (or (next-property-change i fontified)
|
||||||
len)))
|
len)))
|
||||||
(when-let ((face (plist-get props 'face)))
|
(when-let* ((face (plist-get props 'face)))
|
||||||
(setf (plist-get props 'face) nil
|
(setf (plist-get props 'face) nil
|
||||||
(plist-get props 'font-lock-face) face))
|
(plist-get props 'font-lock-face) face))
|
||||||
(set-text-properties (+ start i) (+ start change-i) props)
|
(set-text-properties (+ start i) (+ start change-i) props)
|
||||||
@ -2302,11 +2302,11 @@ Note that this erases the buffer before doing anything."
|
|||||||
(defun my/-jupyter-dont-use-ts-modes (retval)
|
(defun my/-jupyter-dont-use-ts-modes (retval)
|
||||||
"Prevent `jupyter-kernel-language-mode-properties' from selecting TS modes."
|
"Prevent `jupyter-kernel-language-mode-properties' from selecting TS modes."
|
||||||
(cl-destructuring-bind (mode syntax-table) retval
|
(cl-destructuring-bind (mode syntax-table) retval
|
||||||
(if-let (((string-suffix-p "-ts-mode" (symbol-name mode)))
|
(if-let* (((string-suffix-p "-ts-mode" (symbol-name mode)))
|
||||||
(non-ts (car (rassq mode major-mode-remap-alist)))
|
(non-ts (car (rassq mode major-mode-remap-alist)))
|
||||||
((not (string-suffix-p "-ts-mode" (symbol-name non-ts)))))
|
((not (string-suffix-p "-ts-mode" (symbol-name non-ts)))))
|
||||||
(list non-ts
|
(list non-ts
|
||||||
(if-let ((table-sym (intern-soft (format "%s-syntax-table"
|
(if-let* ((table-sym (intern-soft (format "%s-syntax-table"
|
||||||
non-ts))))
|
non-ts))))
|
||||||
(symbol-value table-sym)
|
(symbol-value table-sym)
|
||||||
syntax-table))
|
syntax-table))
|
||||||
@ -2375,7 +2375,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
(jupyter-kernel-language
|
(jupyter-kernel-language
|
||||||
jupyter-current-client))))))
|
jupyter-current-client))))))
|
||||||
(buffer-list))))
|
(buffer-list))))
|
||||||
(when-let (((not res))
|
(when-let* (((not res))
|
||||||
(real (alist-get lang my/jupyter-extra-language-associations nil
|
(real (alist-get lang my/jupyter-extra-language-associations nil
|
||||||
nil #'cl-equalp)))
|
nil #'cl-equalp)))
|
||||||
(setq res (my/-find-jupyter-buffer-for-lang real)))
|
(setq res (my/-find-jupyter-buffer-for-lang real)))
|
||||||
@ -2384,7 +2384,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
(defun my/-jupyter-buffer-for-major-mode (&optional mode)
|
(defun my/-jupyter-buffer-for-major-mode (&optional mode)
|
||||||
"Return a Jupyter buffer that can evaluate the code MODE is editing.
|
"Return a Jupyter buffer that can evaluate the code MODE is editing.
|
||||||
MODE defaults to `major-mode'."
|
MODE defaults to `major-mode'."
|
||||||
(when-let ((name (symbol-name (or mode major-mode)))
|
(when-let* ((name (symbol-name (or mode major-mode)))
|
||||||
((string-match (rx bos (group (+? any)) (? "-ts") "-mode" eos)
|
((string-match (rx bos (group (+? any)) (? "-ts") "-mode" eos)
|
||||||
name)))
|
name)))
|
||||||
(my/-find-jupyter-buffer-for-lang (match-string 1 name))))
|
(my/-find-jupyter-buffer-for-lang (match-string 1 name))))
|
||||||
@ -2400,12 +2400,12 @@ MODE defaults to `major-mode'."
|
|||||||
"Eval CODE a buffer suitable for `major-mode'.
|
"Eval CODE a buffer suitable for `major-mode'.
|
||||||
If NO-ERROR is non-nil, signal an error if a buffer fails to be found. If the
|
If NO-ERROR is non-nil, signal an error if a buffer fails to be found. If the
|
||||||
current buffer is a Jupyter buffer, just use that."
|
current buffer is a Jupyter buffer, just use that."
|
||||||
(interactive (list (if-let ((buffer (my/-jupyter-find-proper-buffer)))
|
(interactive (list (if-let* ((buffer (my/-jupyter-find-proper-buffer)))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(jupyter-read-expression))
|
(jupyter-read-expression))
|
||||||
(user-error "No Jupyter buffer found for mode: %s"
|
(user-error "No Jupyter buffer found for mode: %s"
|
||||||
major-mode))))
|
major-mode))))
|
||||||
(if-let ((buffer (my/-jupyter-find-proper-buffer)))
|
(if-let* ((buffer (my/-jupyter-find-proper-buffer)))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(let ((jupyter-repl-echo-eval-p t))
|
(let ((jupyter-repl-echo-eval-p t))
|
||||||
(jupyter-eval-string code)))
|
(jupyter-eval-string code)))
|
||||||
@ -2415,7 +2415,7 @@ current buffer is a Jupyter buffer, just use that."
|
|||||||
(defun my/jupyter-eval-defun ()
|
(defun my/jupyter-eval-defun ()
|
||||||
"Eval the defun under point by sending it to a Jupyter repl."
|
"Eval the defun under point by sending it to a Jupyter repl."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if-let ((code (thing-at-point 'defun)))
|
(if-let* ((code (thing-at-point 'defun)))
|
||||||
(progn
|
(progn
|
||||||
(my/jupyter-eval-in-proper-buffer code)
|
(my/jupyter-eval-in-proper-buffer code)
|
||||||
(message "Evaluated defun"))
|
(message "Evaluated defun"))
|
||||||
@ -2443,7 +2443,7 @@ current buffer is a Jupyter buffer, just use that."
|
|||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(unless (> (point) start)
|
(unless (> (point) start)
|
||||||
(goto-char start)))
|
(goto-char start)))
|
||||||
(if-let ((thing (treesit-thing-at-point "_" 'nested))
|
(if-let* ((thing (treesit-thing-at-point "_" 'nested))
|
||||||
(code (treesit-node-text thing)))
|
(code (treesit-node-text thing)))
|
||||||
(progn
|
(progn
|
||||||
(my/jupyter-eval-in-proper-buffer code)
|
(my/jupyter-eval-in-proper-buffer code)
|
||||||
@ -2523,7 +2523,7 @@ current buffer is a Jupyter buffer, just use that."
|
|||||||
"Display calculator icons and info."
|
"Display calculator icons and info."
|
||||||
(concat
|
(concat
|
||||||
(doom-modeline-spc)
|
(doom-modeline-spc)
|
||||||
(when-let ((icon (doom-modeline-icon 'faicon "nf-fa-calculator" "🖩" "")))
|
(when-let* ((icon (doom-modeline-icon 'faicon "nf-fa-calculator" "🖩" "")))
|
||||||
(concat
|
(concat
|
||||||
(doom-modeline-display-icon icon)
|
(doom-modeline-display-icon icon)
|
||||||
(doom-modeline-vspc)))
|
(doom-modeline-vspc)))
|
||||||
@ -2687,7 +2687,7 @@ Actually, return the method name."
|
|||||||
(defun my/project-eat (&optional arg prompt)
|
(defun my/project-eat (&optional arg prompt)
|
||||||
"Switch to or create a eat buffer in the current projects root."
|
"Switch to or create a eat buffer in the current projects root."
|
||||||
(interactive (list current-prefix-arg t))
|
(interactive (list current-prefix-arg t))
|
||||||
(if-let ((proj (project-current prompt))
|
(if-let* ((proj (project-current prompt))
|
||||||
(default-directory (project-root proj)))
|
(default-directory (project-root proj)))
|
||||||
(let ((eat-buffer-name (format "*eat for project %s*" default-directory)))
|
(let ((eat-buffer-name (format "*eat for project %s*" default-directory)))
|
||||||
(eat (my/-eat-shell-for-cwd) arg))))
|
(eat (my/-eat-shell-for-cwd) arg))))
|
||||||
@ -2843,7 +2843,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
arg)
|
arg)
|
||||||
(let ((bm-name (match-string 1 arg))
|
(let ((bm-name (match-string 1 arg))
|
||||||
(after-path (match-string 2 arg)))
|
(after-path (match-string 2 arg)))
|
||||||
(when-let ((base (ignore-errors (bookmark-get-filename bm-name)))
|
(when-let* ((base (ignore-errors (bookmark-get-filename bm-name)))
|
||||||
((file-directory-p base))
|
((file-directory-p base))
|
||||||
(abs-path (expand-file-name after-path base))
|
(abs-path (expand-file-name after-path base))
|
||||||
(dir-path (if (string-empty-p after-path)
|
(dir-path (if (string-empty-p after-path)
|
||||||
@ -2994,7 +2994,7 @@ ARG is the same as for either of the above functions."
|
|||||||
(hash-table-p (cdr my/-dirvish-uid-name-cache)))
|
(hash-table-p (cdr my/-dirvish-uid-name-cache)))
|
||||||
(setq my/-dirvish-uid-name-cache
|
(setq my/-dirvish-uid-name-cache
|
||||||
(cons root (make-hash-table :test 'equal))))
|
(cons root (make-hash-table :test 'equal))))
|
||||||
(if-let ((name (gethash uid (cdr my/-dirvish-uid-name-cache))))
|
(if-let* ((name (gethash uid (cdr my/-dirvish-uid-name-cache))))
|
||||||
(setq uid name)
|
(setq uid name)
|
||||||
(let* ((new-attrs (file-attributes f-name 'string))
|
(let* ((new-attrs (file-attributes f-name 'string))
|
||||||
(new-name (file-attribute-user-id new-attrs)))
|
(new-name (file-attribute-user-id new-attrs)))
|
||||||
@ -3390,7 +3390,7 @@ buffers `helpful--sym' to `my/helpful-symbol-history'."
|
|||||||
(not (eq buf helpful-buf))
|
(not (eq buf helpful-buf))
|
||||||
(eq (buffer-local-value 'major-mode buf) 'helpful-mode))
|
(eq (buffer-local-value 'major-mode buf) 'helpful-mode))
|
||||||
do
|
do
|
||||||
(when-let (cur-window (get-buffer-window buf nil))
|
(when-let* ((cur-window (get-buffer-window buf nil)))
|
||||||
(setq window cur-window))
|
(setq window cur-window))
|
||||||
(kill-buffer buf)
|
(kill-buffer buf)
|
||||||
finally
|
finally
|
||||||
@ -3398,9 +3398,9 @@ buffers `helpful--sym' to `my/helpful-symbol-history'."
|
|||||||
(buffer-local-value 'helpful--callable-p
|
(buffer-local-value 'helpful--callable-p
|
||||||
helpful-buf))))
|
helpful-buf))))
|
||||||
(unless my/-helpful-inhibit-history
|
(unless my/-helpful-inhibit-history
|
||||||
(when-let (from-current-hist
|
(when-let* ((from-current-hist
|
||||||
(member my/-helpful-last-entry
|
(member my/-helpful-last-entry
|
||||||
my/helpful-symbol-history))
|
my/helpful-symbol-history)))
|
||||||
(setq my/helpful-symbol-history from-current-hist))
|
(setq my/helpful-symbol-history from-current-hist))
|
||||||
(cl-pushnew entry my/helpful-symbol-history :test 'equal)
|
(cl-pushnew entry my/helpful-symbol-history :test 'equal)
|
||||||
(setq my/helpful-symbol-history
|
(setq my/helpful-symbol-history
|
||||||
@ -3487,7 +3487,7 @@ Color can be any color which can be passed to `color-values'."
|
|||||||
(defun my/-rainbow-delimiters-recalc-dark-faces (&optional frame)
|
(defun my/-rainbow-delimiters-recalc-dark-faces (&optional frame)
|
||||||
(unless frame (setq frame (selected-frame)))
|
(unless frame (setq frame (selected-frame)))
|
||||||
(dotimes (i 9)
|
(dotimes (i 9)
|
||||||
(when-let ((old-face (intern-soft
|
(when-let* ((old-face (intern-soft
|
||||||
(format "rainbow-delimiters-depth-%d-face"
|
(format "rainbow-delimiters-depth-%d-face"
|
||||||
(1+ i))))
|
(1+ i))))
|
||||||
(new-face
|
(new-face
|
||||||
|
|||||||
Reference in New Issue
Block a user