aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Schroeder2017-08-19 10:39:37 +0200
committerAlex Schroeder2017-08-19 10:39:37 +0200
commit82b05985ba55761c497810cf9e14fd530253a1b2 (patch)
treed7d1663f8efe543a1c630439c17bbd5164b9ce0b
parente58b3ef78b7db5190bd940495da6de0b6737f955 (diff)
downloademacs-82b05985ba55761c497810cf9e14fd530253a1b2.tar.gz
emacs-82b05985ba55761c497810cf9e14fd530253a1b2.zip
Use define-minor-mode for rcirc-omit-mode
-rw-r--r--lisp/net/rcirc.el54
1 files changed, 24 insertions, 30 deletions
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."
176 "If non-nil, activity in this buffer is considered low priority.") 176 "If non-nil, activity in this buffer is considered low priority.")
177(make-variable-buffer-local 'rcirc-low-priority-flag) 177(make-variable-buffer-local 'rcirc-low-priority-flag)
178 178
179(defvar rcirc-omit-mode nil 179(defcustom rcirc-omit-responses
180 "Non-nil if Rcirc-Omit mode is enabled. 180 '("JOIN" "PART" "QUIT" "NICK")
181Use the command `rcirc-omit-mode' to change this variable.") 181 "Responses which will be hidden when `rcirc-omit-mode' is enabled."
182(make-variable-buffer-local 'rcirc-omit-mode) 182 :type '(repeat string)
183 :group 'rcirc)
184
185(define-minor-mode rcirc-omit-mode
186 "Toggle the hiding of \"uninteresting\" lines.
187With a prefix argument ARG, enable Rcirc-Omit mode if ARG is
188positive, and disable it otherwise. If called from Lisp, enable
189the mode if ARG is omitted or nil.
190
191Uninteresting lines are those whose responses are listed in
192`rcirc-omit-responses'."
193 nil " Omit" nil
194 (if rcirc-omit-mode
195 (progn
196 (add-to-invisibility-spec '(rcirc-omit . nil))
197 (message "Rcirc-Omit mode enabled"))
198 (remove-from-invisibility-spec '(rcirc-omit . nil))
199 (message "Rcirc-Omit mode disabled"))
200 (dolist (window (get-buffer-window-list (current-buffer)))
201 (with-selected-window window
202 (recenter (when (> (point) rcirc-prompt-start-marker) -1)))))
183 203
184(defcustom rcirc-time-format "%H:%M " 204(defcustom rcirc-time-format "%H:%M "
185 "Describes how timestamps are printed. 205 "Describes how timestamps are printed.
@@ -1405,12 +1425,6 @@ the of the following escape sequences replaced by the described values:
1405 :value-type string) 1425 :value-type string)
1406 :group 'rcirc) 1426 :group 'rcirc)
1407 1427
1408(defcustom rcirc-omit-responses
1409 '("JOIN" "PART" "QUIT" "NICK")
1410 "Responses which will be hidden when `rcirc-omit-mode' is enabled."
1411 :type '(repeat string)
1412 :group 'rcirc)
1413
1414(defun rcirc-format-response-string (process sender response target text) 1428(defun rcirc-format-response-string (process sender response target text)
1415 "Return a nicely-formatted response string, incorporating TEXT 1429 "Return a nicely-formatted response string, incorporating TEXT
1416\(and perhaps other arguments). The specific formatting used 1430\(and perhaps other arguments). The specific formatting used
@@ -1881,9 +1895,6 @@ if ARG is omitted or nil."
1881(or (assq 'rcirc-low-priority-flag minor-mode-alist) 1895(or (assq 'rcirc-low-priority-flag minor-mode-alist)
1882 (setq minor-mode-alist 1896 (setq minor-mode-alist
1883 (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist))) 1897 (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist)))
1884(or (assq 'rcirc-omit-mode minor-mode-alist)
1885 (setq minor-mode-alist
1886 (cons '(rcirc-omit-mode " Omit") minor-mode-alist)))
1887 1898
1888(defun rcirc-toggle-ignore-buffer-activity () 1899(defun rcirc-toggle-ignore-buffer-activity ()
1889 "Toggle the value of `rcirc-ignore-buffer-activity-flag'." 1900 "Toggle the value of `rcirc-ignore-buffer-activity-flag'."
@@ -1905,23 +1916,6 @@ if ARG is omitted or nil."
1905 "Activity in this buffer is normal priority")) 1916 "Activity in this buffer is normal priority"))
1906 (force-mode-line-update)) 1917 (force-mode-line-update))
1907 1918
1908(defun rcirc-omit-mode ()
1909 "Toggle the Rcirc-Omit mode.
1910If enabled, \"uninteresting\" lines are not shown.
1911Uninteresting lines are those whose responses are listed in
1912`rcirc-omit-responses'."
1913 (interactive)
1914 (setq rcirc-omit-mode (not rcirc-omit-mode))
1915 (if rcirc-omit-mode
1916 (progn
1917 (add-to-invisibility-spec '(rcirc-omit . nil))
1918 (message "Rcirc-Omit mode enabled"))
1919 (remove-from-invisibility-spec '(rcirc-omit . nil))
1920 (message "Rcirc-Omit mode disabled"))
1921 (dolist (window (get-buffer-window-list (current-buffer)))
1922 (with-selected-window window
1923 (recenter (when (> (point) rcirc-prompt-start-marker) -1)))))
1924
1925(defun rcirc-switch-to-server-buffer () 1919(defun rcirc-switch-to-server-buffer ()
1926 "Switch to the server buffer associated with current channel buffer." 1920 "Switch to the server buffer associated with current channel buffer."
1927 (interactive) 1921 (interactive)