branch: externals/gtags-mode commit 7dbe784eff8050639502a927b3f2f11d287e9905 Author: Jimmy Aguilar Mena <kratsbinov...@gmail.com> Commit: Jimmy Aguilar Mena <kratsbinov...@gmail.com>
Add accurate verbose levels to control messages. Update the Readme. closes #4 --- Readme.md | 5 +++++ gtags-mode.el | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 01c3daf32d..1577db3b46 100644 --- a/Readme.md +++ b/Readme.md @@ -63,3 +63,8 @@ per individual hosts or users if needed. The custom variable **gtags-mode-lighter** can be used to change the default mode-line message to use when the mode is enabled. +The verbosity of messages printed can be controlled with +**gtags-mode-verbose-level** higher verbose level implies more +messages and 0 prints no messages at all (not recommended!!). The most +verbose messages are not printed in the echo area, but only in the +\*Messages\* buffer. diff --git a/gtags-mode.el b/gtags-mode.el index 33302a595a..a68ff4d946 100644 --- a/gtags-mode.el +++ b/gtags-mode.el @@ -5,7 +5,7 @@ ;; Author: Jimmy Aguilar Mena ;; URL: https://github.com/Ergus/gtags-mode ;; Keywords: xref, project, imenu, gtags, global -;; Version: 1.3 +;; Version: 1.4 ;; Package-Requires: ((emacs "28")) ;; This program is free software: you can redistribute it and/or modify @@ -67,7 +67,7 @@ :type 'string :risky t) -(defcustom gtags-mode-verbose 2 +(defcustom gtags-mode-verbose-level 2 "The text displayed in the mode line." :type 'natnum :risky t) @@ -91,9 +91,13 @@ The address is absolute for remote hosts.") "Command line options to use with `gtags-mode--output-format-regex'.") (defsubst gtags-mode--message (level format-string &rest args) - "Print log messages when the `gtags-mode-verbose' is greater than LEVEL." - (when (>= gtags-mode-verbose level) - (apply #'message (concat "gtags-mode: " format-string) args))) + "Print log messages when the `gtags-mode-verbose' is greater than LEVEL. +Message with lower verbose level are more important. Messages with level +lower than 2 are also printed in the echo area as they are considered +warnings or errors." + (when (>= gtags-mode-verbose-level level) + (let ((inhibit-message (> level 1))) + (apply #'message (concat "gtags-mode: " format-string) args)))) ;; Connection functions (defun gtags-mode--set-connection-locals () @@ -199,7 +203,7 @@ On success return a list of strings or nil if any error occurred." (root (car (gtags-mode--exec-sync '("--print-dbpath"))))) (setq root (concat (file-remote-p default-directory) ;; add remote prefix if remote (file-name-as-directory root))) ;; add a / at the end is missing - (display-warning 'gtags-mode "Option HEEE" :info) + (gtags-mode--message 2 "Gtags file in %s applies to default-directory: %s" root dir) (or (gtags-mode--get-plist root) ;; already exist (car (push `(:gtagsroot ,root :cache nil) gtags-mode--alist)))))