[Emergency fix] spacemacs//mark-repl-as-useful
This function is making asynchronous commands fail because it tries to add string literal to spacemacs-useful-buffers-regexp while add-to-list only works when first argument is a symbol and the second is an element. Otherwise, it throws this error and stop all async commands to do any further work at this point: if: Wrong type argument: symbolp This commit fixes the following issues: - Don't add spacemacs//mark-repl-as-useful to buffer-list-update-hook. We only need this function to switch to next or previous buffer. So, better check when and only when those commands are actually used. - As a result, we remove the function since it's unneeded anymore. - Do the checking in of comint-mode in spacemacs-useful-buffer-p function. Better do it in one place than scatter the logic in a hook and this function. - Change useless-buffer-p to accept an actual buffer object and check for buffer name inside.
This commit is contained in:
parent
ae306b09a9
commit
21ca031492
|
@ -64,9 +64,3 @@ Examples:
|
|||
(push "\\*Messages\\*" spacemacs-useful-buffers-regexp)
|
||||
```
|
||||
|
||||
Most repl buffers are marked useful by default. This behavior can be disabled
|
||||
with the following code:
|
||||
|
||||
```elisp
|
||||
(remove-hook 'after-change-major-mode-hook 'spacemacs//mark-repl-as-useful)
|
||||
```
|
||||
|
|
|
@ -78,8 +78,7 @@
|
|||
(defvar spacemacs-useful-buffers-regexp '("\\*\\(scratch\\|terminal\.\+\\|ansi-term\\|eshell\\)\\*")
|
||||
"Regexp used to define buffers that are useful despite matching
|
||||
`spacemacs-useless-buffers-regexp'.")
|
||||
;; Automatically make comint buffers useful-buffers
|
||||
(add-hook 'buffer-list-update-hook 'spacemacs//mark-repl-as-useful)
|
||||
|
||||
;; activate winner mode use to undo and redo windows layout
|
||||
(winner-mode t)
|
||||
;; no beep pleeeeeease ! (and no visual blinking too please)
|
||||
|
|
|
@ -345,29 +345,28 @@ argument takes the kindows rotate backwards."
|
|||
(interactive "p")
|
||||
(rotate-windows (* -1 count)))
|
||||
|
||||
(defun spacemacs//mark-repl-as-useful ()
|
||||
"Marks all buffers derived from `comint-mode' as useful."
|
||||
(if (eq (get (buffer-local-value 'major-mode (current-buffer)) 'derived-mode-parent)
|
||||
'comint-mode)
|
||||
(add-to-list (format "*\\%s\\*" (replace-regexp-in-string "*" "" (buffer-name)))
|
||||
spacemacs-useful-buffers-regexp)))
|
||||
|
||||
(defun spacemacs/useless-buffer-p (buffer-name)
|
||||
(defun spacemacs/useless-buffer-p (buffer)
|
||||
"Determines if a buffer is useful."
|
||||
(cond ((cl-loop for regexp in spacemacs-useful-buffers-regexp do
|
||||
(if (string-match regexp buffer-name)
|
||||
(return t))) nil)
|
||||
((cl-loop for regexp in spacemacs-useless-buffers-regexp do
|
||||
(if (string-match regexp buffer-name)
|
||||
(return t))) t)
|
||||
(t nil)))
|
||||
(let ((buf-paren-major-mode (get (with-current-buffer buffer
|
||||
major-mode)
|
||||
'derived-mode-parent))
|
||||
(buf-name (buffer-name buffer)))
|
||||
;; first find if useful buffer exists, if so returns nil and don't check for
|
||||
;; useless buffers. If no useful buffer is found, check for useless buffers.
|
||||
(unless (cl-loop for regexp in spacemacs-useful-buffers-regexp do
|
||||
(when (or (eq buf-paren-major-mode 'comint-mode)
|
||||
(string-match regexp buf-name))
|
||||
(return t)))
|
||||
(cl-loop for regexp in spacemacs-useless-buffers-regexp do
|
||||
(when (string-match regexp buf-name)
|
||||
(return t))))))
|
||||
|
||||
(defun spacemacs/next-useful-buffer ()
|
||||
"Switch to the next buffer and avoid special buffers."
|
||||
(interactive)
|
||||
(let ((start-buffer (current-buffer)))
|
||||
(next-buffer)
|
||||
(while (and (spacemacs/useless-buffer-p (buffer-name (current-buffer)))
|
||||
(while (and (spacemacs/useless-buffer-p (current-buffer))
|
||||
(not (eq (current-buffer) start-buffer)))
|
||||
(next-buffer))))
|
||||
|
||||
|
@ -376,7 +375,7 @@ argument takes the kindows rotate backwards."
|
|||
(interactive)
|
||||
(let ((start-buffer (current-buffer)))
|
||||
(previous-buffer)
|
||||
(while (and (spacemacs/useless-buffer-p (buffer-name (current-buffer)))
|
||||
(while (and (spacemacs/useless-buffer-p (current-buffer))
|
||||
(not (eq (current-buffer) start-buffer)))
|
||||
(previous-buffer))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue