unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* rfn-eshadow.el and remote filenames
@ 2007-09-12 21:43 Michael Albinus
  2007-09-13  2:28 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2007-09-12 21:43 UTC (permalink / raw)
  To: emacs-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: rfn-eshadow.el and remote filenames
  2007-09-12 21:43 rfn-eshadow.el and remote filenames Michael Albinus
@ 2007-09-13  2:28 ` Stefan Monnier
  2007-09-13 15:47   ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2007-09-13  2:28 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

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

Current rfn-eshadow.el does not assume anything about the behavior of
substitute-in-file-name and I think we should keep it that way.  Obviously,
it does have some preconceived notion about how substitute-in-file-name
*might* work, but it works safely in "all" cases.

Currently, rfn-eshadow.el only recognizes when substitute-in-file-name drops
a prefix of the current file name, so we need to extend it to recognize
cases where substitute-in-file-name drops some internal part instead.
How to do that efficiently?  I'm not sure.

I'd prefer we find a more general way to do it, but if not, maybe your code
can be kept mostly, but then it should check its result against the return
value of substitute-in-file-name.


        Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: rfn-eshadow.el and remote filenames
  2007-09-13  2:28 ` Stefan Monnier
@ 2007-09-13 15:47   ` Michael Albinus
  2007-09-14  6:41     ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2007-09-13 15:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Current rfn-eshadow.el does not assume anything about the behavior of
> substitute-in-file-name and I think we should keep it that way.  Obviously,
> it does have some preconceived notion about how substitute-in-file-name
> *might* work, but it works safely in "all" cases.
>
> Currently, rfn-eshadow.el only recognizes when substitute-in-file-name drops
> a prefix of the current file name, so we need to extend it to recognize
> cases where substitute-in-file-name drops some internal part instead.
> How to do that efficiently?  I'm not sure.
>
> I'd prefer we find a more general way to do it, but if not, maybe your code
> can be kept mostly, but then it should check its result against the return
> value of substitute-in-file-name.

A more general approach could be when Tramp hooks into
`insert-behind-hooks' of `rfn-eshadow-overlay'. rfn-eshadow.el would
stay unchanged then, likely.

I'll play a little bit with, checking also the performance.

>         Stefan

Best regards, Michael.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: rfn-eshadow.el and remote filenames
  2007-09-13 15:47   ` Michael Albinus
@ 2007-09-14  6:41     ` Michael Albinus
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2007-09-14  6:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

I wrote:

> A more general approach could be when Tramp hooks into
> `insert-behind-hooks' of `rfn-eshadow-overlay'. rfn-eshadow.el would
> stay unchanged then, likely.

That doesn't work, because actions are performed only when exactly at
the end of the overlay a character is inserted.

Instead of, one could add hooks rfn-eshadow-setup-minibuffer-hook and
rfn-eshadow-update-overlay-hook to rfn-eshadow.el. Tramp (and other
packages, potentially) could do their actions then.

> I'll play a little bit with, checking also the performance.

Performance seems to be sufficient.

>>         Stefan

Best regards, Michael.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-14  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-12 21:43 rfn-eshadow.el and remote filenames Michael Albinus
2007-09-13  2:28 ` Stefan Monnier
2007-09-13 15:47   ` Michael Albinus
2007-09-14  6:41     ` Michael Albinus

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).