Mercurial > emacs
comparison lisp/bindings.el @ 48124:110ec10bd1ea
(mode-line-change-eol, mode-line-eol-desc-cache, mode-line-eol-desc): New.
(mode-line-mule-info): Use them for the EOL part of the modeline.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 02 Nov 2002 06:13:57 +0000 |
parents | d6d4b34f5ef8 |
children | 76ff1f8826a6 |
comparison
equal
deleted
inserted
replaced
48123:66755860a8f1 | 48124:110ec10bd1ea |
---|---|
133 (describe-coding-system buffer-file-coding-system))))) | 133 (describe-coding-system buffer-file-coding-system))))) |
134 (purecopy map)) | 134 (purecopy map)) |
135 "Local keymap for the coding-system part of the mode line.") | 135 "Local keymap for the coding-system part of the mode line.") |
136 | 136 |
137 | 137 |
138 (defun mode-line-change-eol () | |
139 "Cycle through the various possible kinds of end-of-line styles." | |
140 (interactive) | |
141 (let ((eol (coding-system-eol-type buffer-file-coding-system))) | |
142 (set-buffer-file-coding-system | |
143 (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix))))) | |
144 | |
145 (defvar mode-line-eol-desc-cache nil) | |
146 | |
147 (defun mode-line-eol-desc () | |
148 (let* ((eol (coding-system-eol-type buffer-file-coding-system)) | |
149 (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system)) | |
150 (desc (assq eol mode-line-eol-desc-cache))) | |
151 (if (and desc (eq (cadr desc) mnemonic)) | |
152 (cddr desc) | |
153 (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale. | |
154 (setq desc | |
155 (propertize | |
156 mnemonic | |
157 'help-echo (format "%s end-of-line; mouse-3 to cycle" | |
158 (if (eq eol 0) "Unix-style LF" | |
159 (if (eq eol 1) "Dos-style CRLF" | |
160 (if (eq eol 2) "Mac-style CR" | |
161 "Undecided")))) | |
162 'keymap | |
163 (eval-when-compile | |
164 (let ((map (make-sparse-keymap))) | |
165 (define-key map [mode-line mouse-3] 'mode-line-change-eol) | |
166 map)))) | |
167 (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) | |
168 desc))) | |
169 | |
138 (defvar mode-line-mule-info | 170 (defvar mode-line-mule-info |
139 `("" | 171 `("" |
140 (current-input-method | 172 (current-input-method |
141 (:propertize ("" current-input-method-title) | 173 (:propertize ("" current-input-method-title) |
142 help-echo (concat | 174 help-echo (concat |
143 "Input method: " | 175 "Input method: " |
144 current-input-method | 176 current-input-method |
145 ". mouse-2: disable, mouse-3: describe") | 177 ". mouse-2: disable, mouse-3: describe") |
146 local-map ,mode-line-input-method-map)) | 178 local-map ,mode-line-input-method-map)) |
147 ,(propertize | 179 ,(propertize |
148 "%Z" | 180 "%z" |
149 'help-echo | 181 'help-echo |
150 #'(lambda (window object point) | 182 #'(lambda (window object point) |
151 (with-current-buffer (window-buffer window) | 183 (with-current-buffer (window-buffer window) |
152 ;; Don't show this tip if the coding system is nil, | 184 ;; Don't show this tip if the coding system is nil, |
153 ;; it reads like a bug, and is not useful anyway. | 185 ;; it reads like a bug, and is not useful anyway. |
155 (if enable-multibyte-characters | 187 (if enable-multibyte-characters |
156 (concat (symbol-name buffer-file-coding-system) | 188 (concat (symbol-name buffer-file-coding-system) |
157 " buffer; mouse-3: describe coding system") | 189 " buffer; mouse-3: describe coding system") |
158 (concat "Unibyte " (symbol-name buffer-file-coding-system) | 190 (concat "Unibyte " (symbol-name buffer-file-coding-system) |
159 " buffer"))))) | 191 " buffer"))))) |
160 'local-map mode-line-coding-system-map)) | 192 'local-map mode-line-coding-system-map) |
193 (:eval (mode-line-eol-desc))) | |
161 "Mode-line control for displaying information of multilingual environment. | 194 "Mode-line control for displaying information of multilingual environment. |
162 Normally it displays current input method (if any activated) and | 195 Normally it displays current input method (if any activated) and |
163 mnemonics of the following coding systems: | 196 mnemonics of the following coding systems: |
164 coding system for saving or writing the current buffer | 197 coding system for saving or writing the current buffer |
165 coding system for keyboard input (if Emacs is running on terminal) | 198 coding system for keyboard input (if Emacs is running on terminal) |
166 coding system for terminal output (if Emacs is running on terminal)" | 199 coding system for terminal output (if Emacs is running on terminal)" |
167 ;;; Currently not: | 200 ;; Currently not: |
168 ;;; coding system for decoding output of buffer process (if any) | 201 ;; coding system for decoding output of buffer process (if any) |
169 ;;; coding system for encoding text to send to buffer process (if any)." | 202 ;; coding system for encoding text to send to buffer process (if any)." |
170 ) | 203 ) |
171 | 204 |
172 (make-variable-buffer-local 'mode-line-mule-info) | 205 (make-variable-buffer-local 'mode-line-mule-info) |
173 | 206 |
174 (defvar mode-line-buffer-identification (purecopy '("%12b")) "\ | 207 (defvar mode-line-buffer-identification (purecopy '("%12b")) "\ |