From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Toggle EOL Date: Fri, 28 Jun 2002 13:07:51 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200206281707.g5SH7pj25406@rum.cs.yale.edu> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1025284285 1941 127.0.0.1 (28 Jun 2002 17:11:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 28 Jun 2002 17:11:25 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17NzHJ-0000VC-00 for ; Fri, 28 Jun 2002 19:11:25 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17NzKU-0003db-00 for ; Fri, 28 Jun 2002 19:14:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17NzFL-0005cD-00; Fri, 28 Jun 2002 13:09:23 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17NzDs-0005Z1-00 for ; Fri, 28 Jun 2002 13:07:52 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g5SH7pj25406; Fri, 28 Jun 2002 13:07:51 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:5244 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:5244 I think that the EOL information in the mode-line should be better separated from the coding-system info. The patch below gives it its own help-echo and its own keymap (mouse-3 switches between the three different possible EOL). Any comment/objection ? Stefan Index: bindings.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v retrieving revision 1.100 diff -u -u -b -r1.100 bindings.el --- bindings.el 16 Apr 2002 14:55:13 -0000 1.100 +++ bindings.el 28 Jun 2002 17:01:15 -0000 @@ -135,6 +135,36 @@ "Local keymap for the coding-system part of the mode line.") +(defvar mode-line-eol-map + (let ((map (make-sparse-keymap))) + (define-key map [mode-line mouse-3] + (lambda () + (interactive) + (let ((eol (coding-system-eol-type buffer-file-coding-system))) + (set-buffer-file-coding-system + (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix)))))) + (purecopy map)) + "Local keymap for the `coding-system-eol-type' part of the mode line.") + +(defvar mode-line-eol-desc-cache nil) + +(defun mode-line-eol-desc () + (let* ((eol (coding-system-eol-type buffer-file-coding-system)) + (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system)) + (desc (assq eol mode-line-eol-desc-cache))) + (if (and desc (eq (cadr desc) mnemonic)) + (cddr desc) + (setq desc + (propertize + mnemonic + 'help-echo (format "%s end-of-line; mouse-3 to change" + (if (eq eol 0) "Unix-style LF" + (if (eq eol 1) "Dos-style CRLF" + (if (eq eol 2) "Mac-style CR" "Undecided")))) + 'keymap mode-line-eol-map)) + (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) + desc))) + (defvar mode-line-mule-info `("" (current-input-method @@ -145,7 +175,7 @@ ". mouse-2: disable, mouse-3: describe") local-map ,mode-line-input-method-map)) ,(propertize - "%Z" + "%z" 'help-echo #'(lambda (window object point) (with-current-buffer (window-buffer window) @@ -157,16 +187,17 @@ " buffer; mouse-3: describe coding system") (concat "Unibyte " (symbol-name buffer-file-coding-system) " buffer"))))) - 'local-map mode-line-coding-system-map)) + 'local-map mode-line-coding-system-map) + (:eval (mode-line-eol-desc)))) "Mode-line control for displaying information of multilingual environment. Normally it displays current input method (if any activated) and mnemonics of the following coding systems: