Mercurial > emacs
comparison lisp/bindings.el @ 38755:2fa1afcedab9
(make-mode-line-mouse-map): Renamed from
make-mode-line-mouse2-map. Take additional arg MOUSE.
(mode-line-modified): Use mouse-3 instead of mouse-2.
(mode-line-buffer-identification-keymap): Bind keys differently.
(propertized-buffer-identification): Adapt help-echo to new
bindings.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 09 Aug 2001 14:06:54 +0000 |
parents | 59cccbc83f43 |
children | 75666bd5d498 |
comparison
equal
deleted
inserted
replaced
38754:b6ae798c9d6e | 38755:2fa1afcedab9 |
---|---|
45 ;;; line as the defvar or defconst. | 45 ;;; line as the defvar or defconst. |
46 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 46 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
47 | 47 |
48 ;;; Code: | 48 ;;; Code: |
49 | 49 |
50 (defun make-mode-line-mouse2-map (f) "\ | 50 (defun make-mode-line-mouse-map (mouse function) "\ |
51 Return a keymap with single entry for mouse-2 on mode line. | 51 Return a keymap with single entry for mouse key MOUSE on the mode line. |
52 This is defined to run function F with no args in the buffer | 52 MOUSE is defined to run function FUNCTION with no args in the buffer |
53 corresponding to the mode line clicked." | 53 corresponding to the mode line clicked." |
54 (let ((map (make-sparse-keymap))) | 54 (let ((map (make-sparse-keymap))) |
55 (define-key map [mode-line mouse-2] f) | 55 (define-key map (vector 'mode-line mouse) function) |
56 map)) | 56 map)) |
57 | 57 |
58 | 58 |
59 (defun mode-line-toggle-read-only (event) | 59 (defun mode-line-toggle-read-only (event) |
60 "Like `toggle-read-only', for the mode-line." | 60 "Like `toggle-read-only', for the mode-line." |
177 | 177 |
178 (defvar mode-line-modified | 178 (defvar mode-line-modified |
179 (list (propertize | 179 (list (propertize |
180 "%1*" | 180 "%1*" |
181 'help-echo (purecopy (lambda (window object point) | 181 'help-echo (purecopy (lambda (window object point) |
182 (format "%sead-only: mouse-2 toggles" | 182 (format "%sead-only: mouse-3 toggles" |
183 (save-selected-window | 183 (save-selected-window |
184 (select-window window) | 184 (select-window window) |
185 (if buffer-read-only | 185 (if buffer-read-only |
186 "R" | 186 "R" |
187 "Not r"))))) | 187 "Not r"))))) |
188 'local-map (purecopy (make-mode-line-mouse2-map | 188 'local-map (purecopy (make-mode-line-mouse-map |
189 'mouse-3 | |
189 #'mode-line-toggle-read-only))) | 190 #'mode-line-toggle-read-only))) |
190 (propertize | 191 (propertize |
191 "%1+" | 192 "%1+" |
192 'help-echo (purecopy (lambda (window object point) | 193 'help-echo (purecopy (lambda (window object point) |
193 (format "%sodified: mouse-2 toggles" | 194 (format "%sodified: mouse-3 toggles" |
194 (save-selected-window | 195 (save-selected-window |
195 (select-window window) | 196 (select-window window) |
196 (if (buffer-modified-p) | 197 (if (buffer-modified-p) |
197 "M" | 198 "M" |
198 "Not m"))))) | 199 "Not m"))))) |
199 'local-map (purecopy (make-mode-line-mouse2-map | 200 'local-map (purecopy (make-mode-line-mouse-map |
200 #'mode-line-toggle-modified)))) | 201 'mouse-3 #'mode-line-toggle-modified)))) |
201 "Mode-line control for displaying whether current buffer is modified.") | 202 "Mode-line control for displaying whether current buffer is modified.") |
202 | 203 |
203 (make-variable-buffer-local 'mode-line-modified) | 204 (make-variable-buffer-local 'mode-line-modified) |
204 | 205 |
205 (setq-default mode-line-format | 206 (setq-default mode-line-format |
220 (propertize " " 'help-echo help-echo) | 221 (propertize " " 'help-echo help-echo) |
221 'global-mode-string | 222 'global-mode-string |
222 (propertize " %[(" 'help-echo help-echo) | 223 (propertize " %[(" 'help-echo help-echo) |
223 '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist | 224 '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist |
224 (propertize "%n" 'help-echo "mouse-2: widen" | 225 (propertize "%n" 'help-echo "mouse-2: widen" |
225 'local-map (make-mode-line-mouse2-map #'mode-line-widen)) | 226 'local-map (make-mode-line-mouse-map |
227 'mouse-2 #'mode-line-widen)) | |
226 (propertize ")%]--" 'help-echo help-echo) | 228 (propertize ")%]--" 'help-echo help-echo) |
227 `(which-func-mode ("" which-func-format ,dashes)) | 229 `(which-func-mode ("" which-func-format ,dashes)) |
228 `(line-number-mode (,(propertize "L%l" 'help-echo help-echo) ,dashes)) | 230 `(line-number-mode (,(propertize "L%l" 'help-echo help-echo) ,dashes)) |
229 `(column-number-mode (,(propertize "C%c" 'help-echo help-echo) ,dashes)) | 231 `(column-number-mode (,(propertize "C%c" 'help-echo help-echo) ,dashes)) |
230 `(-3 . ,(propertize "%p" 'help-echo help-echo)) | 232 `(-3 . ,(propertize "%p" 'help-echo help-echo)) |
242 (list | 244 (list |
243 (list 'abbrev-mode | 245 (list 'abbrev-mode |
244 (propertize " Abbrev" | 246 (propertize " Abbrev" |
245 'help-echo (purecopy | 247 'help-echo (purecopy |
246 "mouse-2: turn off Abbrev mode") | 248 "mouse-2: turn off Abbrev mode") |
247 'local-map (purecopy (make-mode-line-mouse2-map | 249 'local-map (purecopy (make-mode-line-mouse-map |
250 'mouse-2 | |
248 #'mode-line-abbrev-mode)))) | 251 #'mode-line-abbrev-mode)))) |
249 '(overwrite-mode overwrite-mode) | 252 '(overwrite-mode overwrite-mode) |
250 (list 'auto-fill-function | 253 (list 'auto-fill-function |
251 (propertize " Fill" | 254 (propertize " Fill" |
252 'help-echo (purecopy | 255 'help-echo (purecopy |
253 "mouse-2: turn off Autofill mode") | 256 "mouse-2: turn off Autofill mode") |
254 'local-map (purecopy (make-mode-line-mouse2-map | 257 'local-map (purecopy (make-mode-line-mouse-map |
258 'mouse-2 | |
255 #'mode-line-auto-fill-mode)))) | 259 #'mode-line-auto-fill-mode)))) |
256 ;; not really a minor mode... | 260 ;; not really a minor mode... |
257 '(defining-kbd-macro " Def"))) | 261 '(defining-kbd-macro " Def"))) |
258 | 262 |
259 (defvar mode-line-buffer-identification-keymap nil "\ | 263 (defvar mode-line-buffer-identification-keymap nil "\ |
353 (defun mode-line-mode-menu (event) | 357 (defun mode-line-mode-menu (event) |
354 (interactive "@e") | 358 (interactive "@e") |
355 (x-popup-menu event mode-line-mode-menu)) | 359 (x-popup-menu event mode-line-mode-menu)) |
356 | 360 |
357 ;; Add menu of buffer operations to the buffer identification part | 361 ;; Add menu of buffer operations to the buffer identification part |
358 ;; of the mode line. | 362 ;; of the mode line.or header line. |
363 ; | |
359 (let ((map (make-sparse-keymap))) | 364 (let ((map (make-sparse-keymap))) |
360 (define-key map [mode-line mouse-1] 'mode-line-other-buffer) | 365 (define-key map [mode-line mouse-1] 'mode-line-unbury-buffer) |
361 (define-key map [header-line mouse-1] 'mode-line-other-buffer) | 366 (define-key map [header-line mouse-1] 'mode-line-unbury-buffer) |
362 (define-key map [mode-line M-mouse-2] 'mode-line-unbury-buffer) | 367 (define-key map [mode-line mouse-3] 'bury-buffer) |
363 (define-key map [header-line M-mouse-2] 'mode-line-unbury-buffer) | 368 (define-key map [header-line mouse-3] 'bury-buffer) |
364 (define-key map [mode-line mouse-2] 'bury-buffer) | |
365 (define-key map [header-line mouse-2] 'bury-buffer) | |
366 (define-key map [mode-line down-mouse-3] 'mouse-buffer-menu) | |
367 (define-key map [header-line down-mouse-3] 'mouse-buffer-menu) | |
368 (setq mode-line-buffer-identification-keymap map)) | 369 (setq mode-line-buffer-identification-keymap map)) |
369 | 370 |
370 (defun propertized-buffer-identification (fmt) | 371 (defun propertized-buffer-identification (fmt) |
371 "Return a list suitable for `mode-line-buffer-identification'. | 372 "Return a list suitable for `mode-line-buffer-identification'. |
372 FMT is a format specifier such as \"%12b\". This function adds | 373 FMT is a format specifier such as \"%12b\". This function adds |
373 text properties for face, help-echo, and local-map to it." | 374 text properties for face, help-echo, and local-map to it." |
374 (list (propertize fmt | 375 (list (propertize fmt |
375 'face '(:weight bold) | 376 'face '(:weight bold) |
376 'help-echo (purecopy "mouse-1: other \ | 377 'help-echo |
377 buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu") | 378 (purecopy "mouse-1: previous buffer, mouse-3: next buffer") |
378 'local-map mode-line-buffer-identification-keymap))) | 379 'local-map mode-line-buffer-identification-keymap))) |
379 | 380 |
380 (setq-default mode-line-buffer-identification | 381 (setq-default mode-line-buffer-identification |
381 (propertized-buffer-identification "%12b")) | 382 (propertized-buffer-identification "%12b")) |
382 | 383 |