Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace file at point in emacs
    primarykey
    data
    text
    <p>I found the function here for replace filen at point but it doesn't seem to work properly: <a href="http://www.emacswiki.org/emacs/InsertFileName" rel="nofollow">http://www.emacswiki.org/emacs/InsertFileName</a>. It correctly finds the file-at-point but the replace appears to take the file you input and not the file detected originally from what I can see. I'm not sure how to fix this.</p> <p>If I Run the function on /home/testfile</p> <p>First it says file to replace so for example: /home/secondfile Then it says replace '/home/secondfile' with: /home/secondfile and then it says: No file at point</p> <p>Any ideas??</p> <p>Here is the function:</p> <pre><code>(autoload 'ffap-guesser "ffap") (autoload 'ffap-read-file-or-url "ffap") (defun my-replace-file-at-point (currfile newfile) "Replace CURRFILE at point with NEWFILE. When interactive, CURRFILE will need to be confirmed by user and will need to exist on the file system to be recognized, unless it is a URL. NEWFILE does not need to exist. However, Emacs's minibuffer completion can help if it needs to be. " (interactive (let ((currfile (ffap-read-file-or-url "Replace filename: " (ffap-guesser)))) (list currfile (ffap-read-file-or-url (format "Replace `%s' with: " currfile) currfile)))) (save-match-data (if (or (looking-at (regexp-quote currfile)) (let ((filelen (length currfile)) (opoint (point)) (limit (+ (point) (length currfile)))) (save-excursion (goto-char (1- filelen)) (and (search-forward currfile limit 'noerror) (&lt; (match-beginning 0) opoint)) (&gt;= (match-end 0) opoint)))) (replace-match newfile) (error "No file at point to replace")))) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload