jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
359 stars 14 forks source link

indent-bars-mode toggle leaves indent-bars-ts-mode enabled when it should not #60

Closed shipmints closed 1 month ago

shipmints commented 1 month ago

Via C-h m after loading a python buffer with indent-bars-mode enabled via a prog-mode-hook:

Display-Line-Numbers Eldoc Flymake Font-Lock Indent-Bars
Indent-Bars-Ts Jinx Prism-Whitespace Pulsar Rainbow
Ruff-Format-On-Save Show-Paren-Local Subword Yafolding

The major mode is Python-ts mode defined in python.el:

Then after typing M-x indent-bars-mode:

Display-Line-Numbers Eldoc Flymake Font-Lock Indent-Bars-Ts Jinx
Prism-Whitespace Pulsar Rainbow Ruff-Format-On-Save Show-Paren-Local
Subword Yafolding

The major mode is Python-ts mode defined in python.el:
jdtsmith commented 1 month ago

Good catch. It was being disable in all but name. Fixed in 6dc2955; give a try.

shipmints commented 1 month ago

Using master...not working. This could be related to #61 not sure. There's nothing in Messages. I will disable prism entirely and see.

With indent-bars on by default via hook:

Corfu Diff-Hl Display-Line-Numbers Eldoc Electric-Indent-Local Flymake
Font-Lock Highlight-Function-Calls Indent-Bars--Ts Indent-Bars Jinx
Page-Break-Lines Prism Pulsar Rainbow Show-Paren-Local Subword
Yafolding

After manually toggling:

Corfu Diff-Hl Display-Line-Numbers Eldoc Electric-Indent-Local Flymake
Font-Lock Highlight-Function-Calls Indent-Bars--Ts Jinx
Page-Break-Lines Prism Pulsar Rainbow Show-Paren-Local Subword
Yafolding
shipmints commented 1 month ago

The slowdown is still there but much abated without prism loaded at all. But the --ts mode still there.

shipmints commented 1 month ago

Perhaps this is a clue (repeated 800 times):

  (eq arg 'toggle)
  (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))
  (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t)))
  (let ((last-message (current-message))) (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'indent-bars--ts-mode local-minor-modes)) (if indent-bars--ts-mode (progn (setq local-minor-modes (cons 'indent-bars--ts-mode local-minor-modes)))))) (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown)) (run-hooks 'indent-bars--ts-mode-hook (if indent-bars--ts-mode 'indent-bars--ts-mode-on-hook 'indent-bars--ts-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "%s %sabled%s" "Indent-Bars--Ts mode" (if indent-bars--ts-mode "en" "dis") local))))))
  indent-bars--ts-mode(-1)
  indent-bars-ts--teardown()
  (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown))
  (let ((last-message (current-message))) (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'indent-bars--ts-mode local-minor-modes)) (if indent-bars--ts-mode (progn (setq local-minor-modes (cons 'indent-bars--ts-mode local-minor-modes)))))) (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown)) (run-hooks 'indent-bars--ts-mode-hook (if indent-bars--ts-mode 'indent-bars--ts-mode-on-hook 'indent-bars--ts-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "%s %sabled%s" "Indent-Bars--Ts mode" (if indent-bars--ts-mode "en" "dis") local))))))
  indent-bars--ts-mode(-1)
  indent-bars-ts--teardown()
  (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown))
  (let ((last-message (current-message))) (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'indent-bars--ts-mode local-minor-modes)) (if indent-bars--ts-mode (progn (setq local-minor-modes (cons 'indent-bars--ts-mode local-minor-modes)))))) (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown)) (run-hooks 'indent-bars--ts-mode-hook (if indent-bars--ts-mode 'indent-bars--ts-mode-on-hook 'indent-bars--ts-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "%s %sabled%s" "Indent-Bars--Ts mode" (if indent-bars--ts-mode "en" "dis") local))))))
  indent-bars--ts-mode(-1)
  indent-bars-ts--teardown()
  ...snip...
  (let ((last-message (current-message))) (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'indent-bars--ts-mode local-minor-modes)) (if indent-bars--ts-mode (progn (setq local-minor-modes (cons 'indent-bars--ts-mode local-minor-modes)))))) (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown)) (run-hooks 'indent-bars--ts-mode-hook (if indent-bars--ts-mode 'indent-bars--ts-mode-on-hook 'indent-bars--ts-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "%s %sabled%s" "Indent-Bars--Ts mode" (if indent-bars--ts-mode "en" "dis") local))))))
  indent-bars--ts-mode(-1)
  indent-bars-ts--teardown()
  (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown))
  (let ((last-message (current-message))) (setq indent-bars--ts-mode (cond ((eq arg 'toggle) (not indent-bars--ts-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'indent-bars--ts-mode local-minor-modes)) (if indent-bars--ts-mode (progn (setq local-minor-modes (cons 'indent-bars--ts-mode local-minor-modes)))))) (if indent-bars--ts-mode (let* ((s (and t (fboundp #'treesit-available-p))) (s (and s (treesit-available-p))) (lang (and s (treesit-language-at (point-min))))) (if lang (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (indent-bars-ts--teardown)) (run-hooks 'indent-bars--ts-mode-hook (if indent-bars--ts-mode 'indent-bars--ts-mode-on-hook 'indent-bars--ts-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "%s %sabled%s" "Indent-Bars--Ts mode" (if indent-bars--ts-mode "en" "dis") local))))))
  indent-bars--ts-mode(toggle)
  funcall-interactively(indent-bars--ts-mode toggle)
  #<subr call-interactively>(indent-bars--ts-mode record nil)
  apply(#<subr call-interactively> (indent-bars--ts-mode record nil))
  (let* ((bufferlo--anywhere-old-read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function)) (bufferlo--anywhere-nested t) (read-buffer-function #'(lambda (prompt &optional def require-match predicate) (let ((read-buffer-function bufferlo--anywhere-old-read-buffer-function)) (read-buffer prompt def require-match #'...))))) (apply oldfn (list function record-flags keys)))
  (if (or bufferlo--anywhere-tmp-enabled (and (not bufferlo--anywhere-tmp-disabled) (xor (eq bufferlo-anywhere-filter-type 'exclude) (cond ((eq bufferlo-anywhere-filter t) t) ((listp bufferlo-anywhere-filter) (memq function bufferlo-anywhere-filter)) ((functionp bufferlo-anywhere-filter) (funcall bufferlo-anywhere-filter function)))))) (let* ((bufferlo--anywhere-old-read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function)) (bufferlo--anywhere-nested t) (read-buffer-function #'(lambda (prompt &optional def require-match predicate) (let (...) (read-buffer prompt def require-match ...))))) (apply oldfn (list function record-flags keys))) (let ((read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function))) (apply oldfn (list function record-flags keys))))
  bufferlo--interactive-advice(#<subr call-interactively> indent-bars--ts-mode record nil)
  apply(bufferlo--interactive-advice #<subr call-interactively> (indent-bars--ts-mode record nil))
  call-interactively(indent-bars--ts-mode record nil)
  command-execute(indent-bars--ts-mode record)
  execute-extended-command(nil "indent-bars--ts-mode" nil)
  funcall-interactively(execute-extended-command nil "indent-bars--ts-mode" nil)
  #<subr call-interactively>(execute-extended-command nil nil)
  apply(#<subr call-interactively> (execute-extended-command nil nil))
  (let* ((bufferlo--anywhere-old-read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function)) (bufferlo--anywhere-nested t) (read-buffer-function #'(lambda (prompt &optional def require-match predicate) (let ((read-buffer-function bufferlo--anywhere-old-read-buffer-function)) (read-buffer prompt def require-match #'...))))) (apply oldfn (list function record-flags keys)))
  (if (or bufferlo--anywhere-tmp-enabled (and (not bufferlo--anywhere-tmp-disabled) (xor (eq bufferlo-anywhere-filter-type 'exclude) (cond ((eq bufferlo-anywhere-filter t) t) ((listp bufferlo-anywhere-filter) (memq function bufferlo-anywhere-filter)) ((functionp bufferlo-anywhere-filter) (funcall bufferlo-anywhere-filter function)))))) (let* ((bufferlo--anywhere-old-read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function)) (bufferlo--anywhere-nested t) (read-buffer-function #'(lambda (prompt &optional def require-match predicate) (let (...) (read-buffer prompt def require-match ...))))) (apply oldfn (list function record-flags keys))) (let ((read-buffer-function (if bufferlo--anywhere-nested bufferlo--anywhere-old-read-buffer-function read-buffer-function))) (apply oldfn (list function record-flags keys))))
  bufferlo--interactive-advice(#<subr call-interactively> execute-extended-command nil nil)
  apply(bufferlo--interactive-advice #<subr call-interactively> (execute-extended-command nil nil))
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
jdtsmith commented 1 month ago

Ahh, stupid idea. Try master again.

jdtsmith commented 1 month ago

What is the value of indent-bars--ts-mode after you disable?

jdtsmith commented 1 month ago
funcall-interactively(indent-bars--ts-mode toggle)

Did you try to disable the mode yourself? That was the problem (but should be avoided now).

shipmints commented 1 month ago

Yeah, I was experimenting to see if I could track down what it's doing without resorting to debugging it directly.

shipmints commented 1 month ago

You'd think that if it was already torn down, that disabling by hand would be an idempotent no-op.

jdtsmith commented 1 month ago

Is master working for you now?

shipmints commented 1 month ago

Just pulled and restarted. Both this and #61 seem resolved. I deleted the other highlighting indenters so am committed to IBM now. I'll keep using it and report back if other things crop up.