Mercurial > emacs
comparison lisp/erc/erc-goodies.el @ 87952:b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
author | Michael Olson <mwolson@gnu.org> |
---|---|
date | Fri, 25 Jan 2008 03:28:10 +0000 |
parents | 107ccd98fa12 |
children | bef74fdb0ed3 |
comparison
equal
deleted
inserted
replaced
87951:0c208f9e2445 | 87952:b8f89dd3680d |
---|---|
31 | 31 |
32 ;;; Code: | 32 ;;; Code: |
33 | 33 |
34 (require 'erc) | 34 (require 'erc) |
35 | 35 |
36 ;; Imenu Autoload | 36 ;;; Imenu support |
37 (add-hook 'erc-mode-hook | 37 |
38 (lambda () | 38 (defun erc-imenu-setup () |
39 (setq imenu-create-index-function 'erc-create-imenu-index))) | 39 "Setup Imenu support in an ERC buffer." |
40 (set (make-local-variable 'imenu-create-index-function) | |
41 'erc-create-imenu-index)) | |
42 | |
43 (add-hook 'erc-mode-hook 'erc-imenu-setup) | |
40 (autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function") | 44 (autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function") |
41 | 45 |
42 ;;; Automatically scroll to bottom | 46 ;;; Automatically scroll to bottom |
43 (defcustom erc-input-line-position nil | 47 (defcustom erc-input-line-position nil |
44 "Specify where to position the input line when using `erc-scroll-to-bottom'. | 48 "Specify where to position the input line when using `erc-scroll-to-bottom'. |
49 argument to `recenter'." | 53 argument to `recenter'." |
50 :group 'erc-display | 54 :group 'erc-display |
51 :type '(choice integer (const nil))) | 55 :type '(choice integer (const nil))) |
52 | 56 |
53 (define-erc-module scrolltobottom nil | 57 (define-erc-module scrolltobottom nil |
54 "This mode causes the prompt to stay at the end of the window. | 58 "This mode causes the prompt to stay at the end of the window." |
55 You have to activate or deactivate it in already created windows | 59 ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) |
56 separately." | 60 (dolist (buffer (erc-buffer-list)) |
57 ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)) | 61 (with-current-buffer buffer |
58 ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom))) | 62 (erc-add-scroll-to-bottom)))) |
63 ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) | |
64 (dolist (buffer (erc-buffer-list)) | |
65 (with-current-buffer buffer | |
66 (remove-hook 'window-scroll-functions 'erc-scroll-to-bottom t))))) | |
59 | 67 |
60 (defun erc-add-scroll-to-bottom () | 68 (defun erc-add-scroll-to-bottom () |
61 "A hook function for `erc-mode-hook' to recenter output at bottom of window. | 69 "A hook function for `erc-mode-hook' to recenter output at bottom of window. |
62 | 70 |
63 If you find that ERC hangs when using this function, try customizing | 71 If you find that ERC hangs when using this function, try customizing |
108 Put this function on `erc-insert-post-hook' and/or `erc-send-post-hook'." | 116 Put this function on `erc-insert-post-hook' and/or `erc-send-post-hook'." |
109 (put-text-property (point-min) (point-max) 'read-only t) | 117 (put-text-property (point-min) (point-max) 'read-only t) |
110 (put-text-property (point-min) (point-max) 'front-sticky t) | 118 (put-text-property (point-min) (point-max) 'front-sticky t) |
111 (put-text-property (point-min) (point-max) 'rear-nonsticky t)) | 119 (put-text-property (point-min) (point-max) 'rear-nonsticky t)) |
112 | 120 |
113 ;; Distinguish non-commands | 121 ;;; Move to prompt when typing text |
122 (define-erc-module move-to-prompt nil | |
123 "This mode causes the point to be moved to the prompt when typing text." | |
124 ((add-hook 'erc-mode-hook 'erc-move-to-prompt-setup) | |
125 (dolist (buffer (erc-buffer-list)) | |
126 (with-current-buffer buffer | |
127 (erc-move-to-prompt-setup)))) | |
128 ((remove-hook 'erc-mode-hook 'erc-move-to-prompt-setup) | |
129 (dolist (buffer (erc-buffer-list)) | |
130 (with-current-buffer buffer | |
131 (remove-hook 'pre-command-hook 'erc-move-to-prompt t))))) | |
132 | |
133 (defun erc-move-to-prompt () | |
134 "Move the point to the ERC prompt if this is a self-inserting command." | |
135 (when (and erc-input-marker (< (point) erc-input-marker) | |
136 (eq 'self-insert-command this-command)) | |
137 (deactivate-mark) | |
138 (push-mark) | |
139 (goto-char (point-max)))) | |
140 | |
141 (defun erc-move-to-prompt-setup () | |
142 "Initialize the move-to-prompt module for XEmacs." | |
143 (add-hook 'pre-command-hook 'erc-move-to-prompt nil t)) | |
144 | |
145 ;;; Keep place in unvisited channels | |
146 (define-erc-module keep-place nil | |
147 "Leave point above un-viewed text in other channels." | |
148 ((add-hook 'erc-insert-pre-hook 'erc-keep-place)) | |
149 ((remove-hook 'erc-insert-pre-hook 'erc-keep-place))) | |
150 | |
151 (defun erc-keep-place (ignored) | |
152 "Move point away from the last line in a non-selected ERC buffer." | |
153 (when (and (not (eq (window-buffer (selected-window)) | |
154 (current-buffer))) | |
155 (>= (point) erc-insert-marker)) | |
156 (deactivate-mark) | |
157 (goto-char (erc-beg-of-input-line)) | |
158 (forward-line -1))) | |
159 | |
160 ;;; Distinguish non-commands | |
114 (defvar erc-noncommands-list '(erc-cmd-ME | 161 (defvar erc-noncommands-list '(erc-cmd-ME |
115 erc-cmd-COUNTRY | 162 erc-cmd-COUNTRY |
116 erc-cmd-SV | 163 erc-cmd-SV |
117 erc-cmd-SM | 164 erc-cmd-SM |
118 erc-cmd-SMV | 165 erc-cmd-SMV |
494 Add this to `erc-insert-modify-hook' if you happen to be on a | 541 Add this to `erc-insert-modify-hook' if you happen to be on a |
495 channel that has weird people talking in morse to each other. | 542 channel that has weird people talking in morse to each other. |
496 | 543 |
497 See also `unmorse-region'." | 544 See also `unmorse-region'." |
498 (goto-char (point-min)) | 545 (goto-char (point-min)) |
499 (when (re-search-forward "[.-]+\\([.-]+[/ ]\\)+[.-]+" nil t) | 546 (when (re-search-forward "[.-]+\\([.-]*/? *\\)+[.-]+/?" nil t) |
500 (unmorse-region (match-beginning 0) (match-end 0)))) | 547 (save-restriction |
548 (narrow-to-region (match-beginning 0) (match-end 0)) | |
549 ;; Turn " / " into " " | |
550 (goto-char (point-min)) | |
551 (while (re-search-forward " / " nil t) | |
552 (replace-match " ")) | |
553 ;; Turn "/ " into "/" | |
554 (goto-char (point-min)) | |
555 (while (re-search-forward "/ " nil t) | |
556 (replace-match "/")) | |
557 ;; Unmorse region | |
558 (unmorse-region (point-min) (point-max))))) | |
501 | 559 |
502 ;;; erc-occur | 560 ;;; erc-occur |
503 (defun erc-occur (string &optional proc) | 561 (defun erc-occur (string &optional proc) |
504 "Search for STRING in all buffers related to current server. | 562 "Search for STRING in all buffers related to current server. |
505 If called interactively and prefix argument is given, search on all connected | 563 If called interactively and prefix argument is given, search on all connected |