I'm working on a textobject based on ffap-guesser. I'd like for yif to yank the file-at-point. This works great, except when there is no literal file at point, and ffap is doing some of it's more creative guessing.

For example. Running ffap-guesser on

(require 'config-company)

Yields "/home/pythonnut/.emacs.d/modules/config-company.el". Ideally, yif would yank that string instead of what's in the buffer.

I mostly care about yanking, but obviously it would be cool if this worked for other operators. (Deleting, for example, would delete the range that ffap-guesser used to guess?)

Can this be done reasonably?

  • What would you expect dif to delete in that example?
    – Omar
    Commented Dec 10, 2015 at 21:48
  • Whatever ffap used to guess said filename, I suppose.
    – PythonNut
    Commented Dec 10, 2015 at 21:49
  • I bet people would find a text object f confusing if dif deleted different text from that which yif yanked.
    – Omar
    Commented Dec 10, 2015 at 21:55

2 Answers 2


If I remember right, you sometimes use Icicles.

If so, then anytime you are in the minibuffer, you can use M-. to insert text from the buffer, at point, or in fact text derived from that text. Page Inserting Text from Cursor of the Icicles doc describes this feature.

The behavior of M-. is governed by user options icicle-thing-at-point-functions and icicle-default-thing-insertion.

In particular, if library ffap.el is loaded then option icicle-thing-at-point-functions includes ffap-guesser as one of its text-grabbing functions.

This means that you can use M-. to grab /home/pythonnut/.emacs.d/modules/config-company.el into the minibuffer when the cursor is on the library name config-company in the buffer text (require 'config-company).

You can customize icicle-thing-at-point-functions to move the position of ffap-guesser sooner or later in the list of text-grabbing functions that are used when you use M-. repeatedly.

Updated after your comment -

So are you asking for a command that copies to the kill-ring what ffap-guesser returns at point? If so, try this:

(defun ffap-guesser-copy (&optional msgp)
  (interactive "p")
  (let ((text  (kill-new (ffap-guesser))))
    (when msgp (message "Copied `%s to kill ring" text))))

(global-set-key "\C-o" 'ffap-guesser-copy)
  • That's neat, and thanks for the tip; that binding looks super useful. However, my most common use-case for this textobject is actually copying the file path to external programs by way of the clipboard.
    – PythonNut
    Commented Sep 10, 2015 at 16:07

What you're proposing isn't really a text object. To recap:

Text objects are defined with evil-define-text-object. In Visual state, they modify the current selection; in Operator-Pending state, they return a pair of buffer positions. Outer text objects are bound in the keymap evil-outer-text-objects-map, and inner text objects are bound in evil-inner-text-objects-map.

Common text objects like words, WORDS, paragraphs and sentences are defined via a corresponding move-function. […]

The definition of a text object as movement means that it must be part of the buffer to allow each Evil operator to work upon it. If you look at the arguments of evil-delete for example, you'll notice the first two are BEG and END.

Therefore I can only imagine the approach of overloading the operators you have in mind to work. It isn't nearly as easy to do as in Vim (where you just override a mapping with your custom command and are done), but still possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.