all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: emacs-devel@gnu.org
Subject: rfn-eshadow.el and remote filenames
Date: Wed, 12 Sep 2007 23:43:43 +0200	[thread overview]
Message-ID: <874phzsgog.fsf@gmx.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

Hi,

Tramp has an own implementation of substitute-in-file-name, which
substitutes "//" and "/~" in the local filename part. In order to make
it visible in the minibuffer, I'ld like to install the appended patch in
the trunk.

If you want to see it, type something like "/tmp//su::/etc//us <TAB>" in
the minibuffer, when opening a file.

Any objections?

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 4655 bytes --]

*** /home/albinus/src/emacs/lisp/rfn-eshadow.el.~1.25.~	2007-07-26 07:31:01.000000000 +0200
--- /home/albinus/src/emacs/lisp/rfn-eshadow.el	2007-09-12 23:21:52.000000000 +0200
***************
*** 130,135 ****
--- 130,140 ----
  (defvar rfn-eshadow-overlay)
  (make-variable-buffer-local 'rfn-eshadow-overlay)
  
+ ;; An overlay covering the shadowed local filename part of a remote
+ ;; filename (local to the minibuffer).
+ (defvar rfn-eshadow-remote-overlay)
+ (make-variable-buffer-local 'rfn-eshadow-remote-overlay)
+ 
  \f
  ;;; Hook functions
  
***************
*** 140,156 ****
    (when minibuffer-completing-file-name
      (setq rfn-eshadow-overlay
  	  (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
      ;; Give rfn-eshadow-overlay the user's props.
      (let ((props
  	   (if window-system
  	       file-name-shadow-properties
  	     file-name-shadow-tty-properties)))
        (while props
! 	(overlay-put rfn-eshadow-overlay (pop props) (pop props))))
      ;; Turn on overlay evaporation so that we don't have to worry about
      ;; odd effects when the overlay sits empty at the beginning of the
      ;; minibuffer.
      (overlay-put rfn-eshadow-overlay 'evaporate t)
      ;; Add our post-command hook, and make sure can remove it later.
      (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
      (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)))
--- 145,167 ----
    (when minibuffer-completing-file-name
      (setq rfn-eshadow-overlay
  	  (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
+     (setq rfn-eshadow-remote-overlay
+ 	  (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
      ;; Give rfn-eshadow-overlay the user's props.
      (let ((props
  	   (if window-system
  	       file-name-shadow-properties
  	     file-name-shadow-tty-properties)))
        (while props
! 	(let ((prop (pop props))
! 	      (value (pop props)))
! 	  (overlay-put rfn-eshadow-overlay prop value)
! 	  (overlay-put rfn-eshadow-remote-overlay prop value))))
      ;; Turn on overlay evaporation so that we don't have to worry about
      ;; odd effects when the overlay sits empty at the beginning of the
      ;; minibuffer.
      (overlay-put rfn-eshadow-overlay 'evaporate t)
+     (overlay-put rfn-eshadow-remote-overlay 'evaporate t)
      ;; Add our post-command hook, and make sure can remove it later.
      (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
      (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)))
***************
*** 168,176 ****
  This is intended to be used as a minibuffer `post-command-hook' for
  `file-name-shadow-mode'; the minibuffer should have already
  been set up by `rfn-eshadow-setup-minibuffer'."
    (condition-case nil
        (let ((goal (substitute-in-file-name (minibuffer-contents)))
!             (mid (overlay-end rfn-eshadow-overlay))
              (start (minibuffer-prompt-end))
              (end (point-max)))
          (unless
--- 179,200 ----
  This is intended to be used as a minibuffer `post-command-hook' for
  `file-name-shadow-mode'; the minibuffer should have already
  been set up by `rfn-eshadow-setup-minibuffer'."
+   ;; Shadow from the beginning.
+   (rfn-eshadow-do-overlay rfn-eshadow-overlay)
+ 
+   ;; In remote files name, there is a shadowing just for the local part.
+   (let ((x (or (overlay-end rfn-eshadow-overlay) (minibuffer-prompt-end))))
+     (when (file-remote-p (buffer-substring-no-properties x (point-max)))
+       (narrow-to-region
+        (1+ (or (string-match "/" (buffer-string) x) x)) (point-max))
+       (rfn-eshadow-do-overlay rfn-eshadow-remote-overlay)
+       (widen))))
+ 
+ (defun rfn-eshadow-do-overlay (overlay)
+   "Apply `rfn-eshadow-overlay' to cover shadowed part of minibuffer input."
    (condition-case nil
        (let ((goal (substitute-in-file-name (minibuffer-contents)))
!             (mid (overlay-end overlay))
              (start (minibuffer-prompt-end))
              (end (point-max)))
          (unless
***************
*** 193,199 ****
              (if (rfn-eshadow-sifn-equal goal mid)
                  (setq start mid)
                (setq end mid)))
!           (move-overlay rfn-eshadow-overlay (minibuffer-prompt-end) start)))
      ;; `substitute-in-file-name' can fail on partial input.
      (error nil)))
  \f
--- 217,223 ----
              (if (rfn-eshadow-sifn-equal goal mid)
                  (setq start mid)
                (setq end mid)))
!           (move-overlay overlay (minibuffer-prompt-end) start)))
      ;; `substitute-in-file-name' can fail on partial input.
      (error nil)))
  \f

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-09-12 21:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-12 21:43 Michael Albinus [this message]
2007-09-13  2:28 ` rfn-eshadow.el and remote filenames Stefan Monnier
2007-09-13 15:47   ` Michael Albinus
2007-09-14  6:41     ` Michael Albinus

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=874phzsgog.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    /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.