unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16648: [PATCH] Improved ffap-completable
@ 2014-02-05  7:14 E Sabof
  2016-02-24  3:23 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: E Sabof @ 2014-02-05  7:14 UTC (permalink / raw)
  To: 16648

Assuming that point is at the word "The", and the complete filename follows. The current version will work when the default-directory contains one file "The first file.txt". But it won't if there is another file "The second file.txt", since file-name-completion will only give a partial completion.

Evgeni

diff --git a/lisp/ffap.el b/lisp/ffap.el
index bb0f61d..4655639 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -819,8 +819,28 @@ URL, or nil.  If nil, search the alist for further matches.")

 (defun ffap-completable (name)
   (let* ((dir (or (file-name-directory name) default-directory))
-	 (cmp (file-name-completion (file-name-nondirectory name) dir)))
-    (and cmp (concat dir cmp))))
+         (completions (file-name-all-completions
+                       (file-name-nondirectory name) dir))
+         (looking-at-candidate
+          (lambda (candidate)
+            (string-equal (buffer-substring
+                           (point)
+                           (min (+ (point) (length candidate))
+                                (point-max)))
+                          candidate)))
+         start)
+    (when (and completions (cdr completions))
+      (setq completions
+            (or (cl-remove-if-not looking-at-candidate
+                                  completions)
+                (and (setq start (car (bounds-of-thing-at-point 'symbol)))
+                     (/= start (point))
+                     (save-excursion
+                       (goto-char start)
+                       (cl-remove-if-not looking-at-candidate
+                                         completions))))))
+    (when completions
+      (concat dir (car completions)))))

 (defun ffap-home (name) (ffap-locate-file name t '("~")))





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

* bug#16648: [PATCH] Improved ffap-completable
  2014-02-05  7:14 bug#16648: [PATCH] Improved ffap-completable E Sabof
@ 2016-02-24  3:23 ` Lars Ingebrigtsen
  2019-06-26 14:44   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-24  3:23 UTC (permalink / raw)
  To: E Sabof; +Cc: 16648

E Sabof <esabof@gmail.com> writes:

> Assuming that point is at the word "The", and the complete filename
> follows. The current version will work when the default-directory
> contains one file "The first file.txt". But it won't if there is
> another file "The second file.txt", since file-name-completion will
> only give a partial completion.

I think the patch below looks reasonable, but I rarely use ffap, so I'm
not quite sure.  Anybody have an opinion?

Also, this patch is more than 15 lines, so we need FSF copyright
assignment papers before applying it.  Would you be willing so sign such
papers?

>
> diff --git a/lisp/ffap.el b/lisp/ffap.el
> index bb0f61d..4655639 100644
> --- a/lisp/ffap.el
> +++ b/lisp/ffap.el
> @@ -819,8 +819,28 @@ URL, or nil.  If nil, search the alist for further matches.")
>
>  (defun ffap-completable (name)
>    (let* ((dir (or (file-name-directory name) default-directory))
> -	 (cmp (file-name-completion (file-name-nondirectory name) dir)))
> -    (and cmp (concat dir cmp))))
> +         (completions (file-name-all-completions
> +                       (file-name-nondirectory name) dir))
> +         (looking-at-candidate
> +          (lambda (candidate)
> +            (string-equal (buffer-substring
> +                           (point)
> +                           (min (+ (point) (length candidate))
> +                                (point-max)))
> +                          candidate)))
> +         start)
> +    (when (and completions (cdr completions))
> +      (setq completions
> +            (or (cl-remove-if-not looking-at-candidate
> +                                  completions)
> +                (and (setq start (car (bounds-of-thing-at-point 'symbol)))
> +                     (/= start (point))
> +                     (save-excursion
> +                       (goto-char start)
> +                       (cl-remove-if-not looking-at-candidate
> +                                         completions))))))
> +    (when completions
> +      (concat dir (car completions)))))
>
>  (defun ffap-home (name) (ffap-locate-file name t '("~")))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#16648: [PATCH] Improved ffap-completable
  2016-02-24  3:23 ` Lars Ingebrigtsen
@ 2019-06-26 14:44   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-26 14:44 UTC (permalink / raw)
  To: E Sabof; +Cc: 16648

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Also, this patch is more than 15 lines, so we need FSF copyright
> assignment papers before applying it.  Would you be willing so sign such
> papers?

This was asked three years ago about a two year old patch, so I don't
think there's going to be any progress here, and I'm closing the bug
report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2019-06-26 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05  7:14 bug#16648: [PATCH] Improved ffap-completable E Sabof
2016-02-24  3:23 ` Lars Ingebrigtsen
2019-06-26 14:44   ` Lars Ingebrigtsen

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