From: Lars Ingebrigtsen <larsi@gnus.org>
To: E Sabof <esabof@gmail.com>
Cc: 16648@debbugs.gnu.org
Subject: bug#16648: [PATCH] Improved ffap-completable
Date: Wed, 24 Feb 2016 14:23:54 +1100 [thread overview]
Message-ID: <874mcyn645.fsf@gnus.org> (raw)
In-Reply-To: <87txcef2uj.fsf@gmail.com> (E. Sabof's message of "Wed, 05 Feb 2014 07:14:28 +0000")
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
next prev parent reply other threads:[~2016-02-24 3:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-05 7:14 bug#16648: [PATCH] Improved ffap-completable E Sabof
2016-02-24 3:23 ` Lars Ingebrigtsen [this message]
2019-06-26 14:44 ` Lars Ingebrigtsen
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=874mcyn645.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=16648@debbugs.gnu.org \
--cc=esabof@gmail.com \
/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.