diff options
author | Yuchen Pei <id@ypei.org> | 2024-05-09 19:54:35 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2024-05-09 19:54:35 +1000 |
commit | c725c4d789ba6d1a7fa2ee3107fe443639bae724 (patch) | |
tree | 910716493f4a0ca604024d5e6a9881911d2a8677 | |
parent | 13ab7e08cb0abe626f9c5cf678b6049db7251909 (diff) |
[emacs] disable which-function in json mode when buffer is big
-rw-r--r-- | emacs/.emacs.d/init/ycp-markup.el | 2 | ||||
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-prog.el | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/emacs/.emacs.d/init/ycp-markup.el b/emacs/.emacs.d/init/ycp-markup.el index 843accd..e03fd86 100644 --- a/emacs/.emacs.d/init/ycp-markup.el +++ b/emacs/.emacs.d/init/ycp-markup.el @@ -101,7 +101,7 @@ (:delay 30) (:install t) (require 'my-prog) - (add-hook 'json-mode-hook 'my-json-set-header-line-hook) + (add-hook 'json-mode-hook 'my-json-setup-hook) ) (provide 'ycp-markup) diff --git a/emacs/.emacs.d/lisp/my/my-prog.el b/emacs/.emacs.d/lisp/my/my-prog.el index 7e37611..9d6a778 100644 --- a/emacs/.emacs.d/lisp/my/my-prog.el +++ b/emacs/.emacs.d/lisp/my/my-prog.el @@ -149,7 +149,7 @@ (cons 'annotation-function (lambda (c) (alist-get c pairs nil nil #'equal))))) - (t + (_ (if (string-blank-p str) (all-completions str pairs) (all-completions @@ -241,7 +241,7 @@ With a prefix arg, convert from bottom to top." (cond ((not file-location-from) file-location-at) ((not file-location-at) file-location-from) ((< point-at point-from) file-location-at) - (t file-location-from))) + (_ file-location-from))) (when (and func-name file-location) (push (concat "[[" file-location "][" func-name "]]") results)))) (unless current-prefix-arg (setq results (reverse results))) @@ -415,8 +415,10 @@ left and the source buffer on the right. (mapcar 'prin1-to-string (plist-get (json-path-to-position (point)) :path)) "/")) -(defun my-json-set-header-line-hook () - (when (< (point-max) 100000) (my-json-set-header-line-to-path))) +(defun my-json-setup-hook () + (if (< (point-max) 100000) + (my-json-set-header-line-to-path) + (setq which-func-mode nil))) (defun my-json-set-header-line-to-path () (setq header-line-format |