all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: mode-line with Tramp
Date: Wed, 18 Jul 2007 20:43:46 +1200	[thread overview]
Message-ID: <18077.53954.67784.465789@kahikatea.snap.net.nz> (raw)
In-Reply-To: <nqk5sz43dv.fsf@alcatel-lucent.de>

 > > 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

  reply	other threads:[~2007-07-18  8:43 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09  8:51 Tramp with GUD broken on trunk? Nick Roberts
2007-07-09 10:10 ` Michael Albinus
2007-07-09 10:35   ` Nick Roberts
2007-07-09 11:20     ` Michael Albinus
2007-07-10  2:03       ` Nick Roberts
2007-07-10  4:42         ` Michael Albinus
2007-07-10 14:14           ` Stefan Monnier
2007-07-10 14:39             ` Michael Albinus
2007-07-10 15:04               ` Stefan Monnier
2007-07-10 15:14                 ` Michael Albinus
2007-07-10 18:14                   ` Stefan Monnier
2007-07-10 19:55                     ` Michael Albinus
2007-07-10 22:27                       ` Nick Roberts
2007-07-11  2:10                       ` Nick Roberts
2007-07-11  5:59                         ` Michael Albinus
2007-07-11  7:44                       ` Nick Roberts
2007-07-11  7:58                         ` Michael Albinus
2007-07-11 19:42                         ` Michael Albinus
2007-07-11 22:32                           ` Nick Roberts
2007-07-12 15:36                             ` Michael Albinus
2007-07-12 21:17                               ` Michael Albinus
2007-07-12 22:40                                 ` Nick Roberts
2007-07-12 22:39                               ` mode-line with Tramp [was: Re: Tramp with GUD broken on trunk?] Nick Roberts
2007-07-15  9:20                                 ` mode-line with Tramp Michael Albinus
2007-07-16 23:17                                   ` Nick Roberts
2007-07-17 12:32                                     ` Michael Albinus
2007-07-18  8:43                                       ` Nick Roberts [this message]
2007-07-19 10:35                                         ` Michael Albinus
2007-07-19 21:21                                           ` Richard Stallman
2007-07-19 23:28                                             ` Nick Roberts
2007-07-21  4:52                                               ` Richard Stallman
2007-07-21  9:07                                                 ` Nick Roberts
2007-07-21  9:33                                                   ` Eli Zaretskii
2007-07-22  1:49                                                   ` Richard Stallman
2007-07-21  9:46                                               ` Eli Zaretskii
2007-07-21 23:12                                                 ` Nick Roberts
2007-07-22 18:36                                                   ` Richard Stallman
2007-07-21 19:04                                               ` Juri Linkov
2007-07-21 20:20                                                 ` David Kastrup
2007-07-21 23:10                                                 ` Nick Roberts
2007-07-22 18:36                                                   ` Richard Stallman
2007-07-22 19:24                                                     ` Michael Albinus
2007-07-22 22:39                                                     ` Nick Roberts
2007-07-22 21:47                                                   ` Juri Linkov
2007-07-22 22:36                                                     ` Nick Roberts
2007-07-22 18:36                                                 ` Richard Stallman
2007-07-22 23:25                                                   ` Nick Roberts
2007-07-23  7:56                                                     ` Michael Albinus
2007-07-23 20:58                                                       ` Nick Roberts
2007-07-23 18:06                                                     ` Richard Stallman
2007-07-23 21:28                                                       ` Nick Roberts
2007-07-23 21:34                                                     ` Juri Linkov
2007-07-23 22:46                                                       ` Nick Roberts
2007-07-25 22:26                                                         ` Nick Roberts
2007-07-26  8:51                                                           ` Juri Linkov
2007-07-26 16:59                                                           ` Richard Stallman
2007-07-27 23:05                                                     ` Johan Bockgård
2007-07-27 23:52                                                       ` Nick Roberts
2007-07-20  6:42                                             ` Michael Albinus
2007-07-21  4:51                                               ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18077.53954.67784.465789@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.