From: Alex Schroeder Date: Sat, 19 Aug 2017 08:39:37 +0000 (+0200) Subject: Use define-minor-mode for rcirc-omit-mode X-Git-Tag: emacs-26.0.90~411 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82b05985ba55761c497810cf9e14fd530253a1b2;p=emacs.git Use define-minor-mode for rcirc-omit-mode --- diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index ddff25c1e92..c01ece9641d 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -176,10 +176,30 @@ underneath each nick." "If non-nil, activity in this buffer is considered low priority.") (make-variable-buffer-local 'rcirc-low-priority-flag) -(defvar rcirc-omit-mode nil - "Non-nil if Rcirc-Omit mode is enabled. -Use the command `rcirc-omit-mode' to change this variable.") -(make-variable-buffer-local 'rcirc-omit-mode) +(defcustom rcirc-omit-responses + '("JOIN" "PART" "QUIT" "NICK") + "Responses which will be hidden when `rcirc-omit-mode' is enabled." + :type '(repeat string) + :group 'rcirc) + +(define-minor-mode rcirc-omit-mode + "Toggle the hiding of \"uninteresting\" lines. +With a prefix argument ARG, enable Rcirc-Omit mode if ARG is +positive, and disable it otherwise. If called from Lisp, enable +the mode if ARG is omitted or nil. + +Uninteresting lines are those whose responses are listed in +`rcirc-omit-responses'." + nil " Omit" nil + (if rcirc-omit-mode + (progn + (add-to-invisibility-spec '(rcirc-omit . nil)) + (message "Rcirc-Omit mode enabled")) + (remove-from-invisibility-spec '(rcirc-omit . nil)) + (message "Rcirc-Omit mode disabled")) + (dolist (window (get-buffer-window-list (current-buffer))) + (with-selected-window window + (recenter (when (> (point) rcirc-prompt-start-marker) -1))))) (defcustom rcirc-time-format "%H:%M " "Describes how timestamps are printed. @@ -1405,12 +1425,6 @@ the of the following escape sequences replaced by the described values: :value-type string) :group 'rcirc) -(defcustom rcirc-omit-responses - '("JOIN" "PART" "QUIT" "NICK") - "Responses which will be hidden when `rcirc-omit-mode' is enabled." - :type '(repeat string) - :group 'rcirc) - (defun rcirc-format-response-string (process sender response target text) "Return a nicely-formatted response string, incorporating TEXT \(and perhaps other arguments). The specific formatting used @@ -1881,9 +1895,6 @@ if ARG is omitted or nil." (or (assq 'rcirc-low-priority-flag minor-mode-alist) (setq minor-mode-alist (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist))) -(or (assq 'rcirc-omit-mode minor-mode-alist) - (setq minor-mode-alist - (cons '(rcirc-omit-mode " Omit") minor-mode-alist))) (defun rcirc-toggle-ignore-buffer-activity () "Toggle the value of `rcirc-ignore-buffer-activity-flag'." @@ -1905,23 +1916,6 @@ if ARG is omitted or nil." "Activity in this buffer is normal priority")) (force-mode-line-update)) -(defun rcirc-omit-mode () - "Toggle the Rcirc-Omit mode. -If enabled, \"uninteresting\" lines are not shown. -Uninteresting lines are those whose responses are listed in -`rcirc-omit-responses'." - (interactive) - (setq rcirc-omit-mode (not rcirc-omit-mode)) - (if rcirc-omit-mode - (progn - (add-to-invisibility-spec '(rcirc-omit . nil)) - (message "Rcirc-Omit mode enabled")) - (remove-from-invisibility-spec '(rcirc-omit . nil)) - (message "Rcirc-Omit mode disabled")) - (dolist (window (get-buffer-window-list (current-buffer))) - (with-selected-window window - (recenter (when (> (point) rcirc-prompt-start-marker) -1))))) - (defun rcirc-switch-to-server-buffer () "Switch to the server buffer associated with current channel buffer." (interactive)