From c725c4d789ba6d1a7fa2ee3107fe443639bae724 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 9 May 2024 19:54:35 +1000 Subject: [emacs] disable which-function in json mode when buffer is big --- emacs/.emacs.d/init/ycp-markup.el | 2 +- 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 -- cgit v1.2.3