[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mode-line with Tramp
From: |
Nick Roberts |
Subject: |
Re: mode-line with Tramp |
Date: |
Wed, 18 Jul 2007 20:43:46 +1200 |
> > And %R (not implemented yet) works a bit like %*: print R or hyphen
> > depending on whether (file-remote-p default-directory) is true or not.
>
> I don't know whether it is OK to call pure Lisp functions in
> decode_mode_spec. Besides of this, it looks natural to me.
(Apart from this?)
Using call1 seems to work. The function file-remote-p is in file.el which gets
built into Emacs through loadup.el, so I guess it's OK.
> And one could also think about a host indication %h, which is a
> candidate for frame-title-format or header-line-format.
>
> However, I'm rather chary with changes in xdisp.c, bindings.el etc,
> because I don't know whether they are accepted by the majority.
It's just one character on the mode-line. Here's a patch that they can try.
--
Nick http://www.inet.net.nz/~nickrob
Index: src/xdisp.c
===================================================================
RCS file: /sources/emacs/emacs/src/xdisp.c,v
retrieving revision 1.1156
diff -p -r1.1156 xdisp.c
*** src/xdisp.c 17 Jun 2007 01:45:46 -0000 1.1156
--- src/xdisp.c 18 Jul 2007 08:38:44 -0000
*************** decode_mode_spec (w, c, field_width, pre
*** 17994,17999 ****
--- 17994,18009 ----
#endif
break;
+ case 'R':
+ {
+ Lisp_Object val;
+ val = call1 (intern ("file-remote-p"), current_buffer->directory);
+ if (NILP (val))
+ return "-";
+ else
+ return "R";
+ }
+
case 't': /* indicate TEXT or BINARY */
#ifdef MODE_LINE_BINARY_TEXT
return MODE_LINE_BINARY_TEXT (b);
Index: src/buffer.c
===================================================================
RCS file: /sources/emacs/emacs/src/buffer.c,v
retrieving revision 1.528
diff -p -r1.528 buffer.c
*** src/buffer.c 27 Jun 2007 11:33:29 -0000 1.528
--- src/buffer.c 18 Jul 2007 08:38:51 -0000
*************** A string is printed verbatim in the mode
*** 5501,5506 ****
--- 5501,5508 ----
%P -- print percent of buffer above bottom of window, perhaps plus Top,
or print Bottom or All.
%n -- print Narrow if appropriate.
+ %R -- print R or hyphen. R means that default-directory is on a
+ remote machine.
%t -- visited file is text or binary (if OS supports this distinction).
%z -- print mnemonics of keyboard, terminal, and buffer coding systems.
%Z -- like %z, but including the end-of-line format.
Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.178
diff -p -r1.178 bindings.el
*** lisp/bindings.el 11 Feb 2007 22:11:48 -0000 1.178
--- lisp/bindings.el 18 Jul 2007 08:38:53 -0000
*************** Normally nil in most modes, since there
*** 248,253 ****
--- 248,270 ----
(make-variable-buffer-local 'mode-line-modified)
+ (defvar mode-line-remote
+ (list (propertize
+ "%1R"
+ 'help-echo (purecopy (lambda (window object point)
+ (format "%s"
+ (save-selected-window
+ (select-window window)
+ (concat
+ (if (file-remote-p default-directory)
+ "Remote: "
+ "Local: ")
+ default-directory)))))))
+ "Mode-line flag to show if default-directory for the current buffer
+ is on a remote machine.")
+
+ (make-variable-buffer-local 'mode-line-remote)
+
;; Actual initialization is below.
(defvar mode-line-position nil
"Mode-line control for displaying the position in the buffer.
*************** Keymap to display on minor modes.")
*** 287,292 ****
--- 304,310 ----
(propertize "-" 'help-echo help-echo)
'mode-line-mule-info
'mode-line-modified
+ 'mode-line-remote
'mode-line-frame-identification
'mode-line-buffer-identification
(propertize " " 'help-echo help-echo)
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.912
diff -p -r1.912 files.el
*** lisp/files.el 17 Jul 2007 21:07:49 -0000 1.912
--- lisp/files.el 18 Jul 2007 08:39:02 -0000
*************** asking you for confirmation."
*** 2464,2469 ****
--- 2464,2470 ----
mode-line-mule-info
mode-line-position
mode-line-process
+ mode-line-remote
mode-name
outline-level
overriding-local-map
- Re: Tramp with GUD broken on trunk?, (continued)
- Re: Tramp with GUD broken on trunk?, Michael Albinus, 2007/07/11
- Re: Tramp with GUD broken on trunk?, Nick Roberts, 2007/07/11
- Re: Tramp with GUD broken on trunk?, Michael Albinus, 2007/07/11
- Re: Tramp with GUD broken on trunk?, Michael Albinus, 2007/07/11
- Re: Tramp with GUD broken on trunk?, Nick Roberts, 2007/07/11
- Re: Tramp with GUD broken on trunk?, Michael Albinus, 2007/07/12
- mode-line with Tramp [was: Re: Tramp with GUD broken on trunk?], Nick Roberts, 2007/07/12
- Re: mode-line with Tramp, Michael Albinus, 2007/07/15
- Re: mode-line with Tramp, Nick Roberts, 2007/07/16
- Re: mode-line with Tramp, Michael Albinus, 2007/07/17
- Re: mode-line with Tramp,
Nick Roberts <=
- Re: mode-line with Tramp, Michael Albinus, 2007/07/19
- Re: mode-line with Tramp, Richard Stallman, 2007/07/19
- Re: mode-line with Tramp, Nick Roberts, 2007/07/19
- Re: mode-line with Tramp, Richard Stallman, 2007/07/21
- Re: mode-line with Tramp, Nick Roberts, 2007/07/21
- Re: mode-line with Tramp, Eli Zaretskii, 2007/07/21
- Re: mode-line with Tramp, Richard Stallman, 2007/07/21
- Re: mode-line with Tramp, Eli Zaretskii, 2007/07/21
- Re: mode-line with Tramp, Nick Roberts, 2007/07/21
- Re: mode-line with Tramp, Richard Stallman, 2007/07/22