So I wanted to basically copy the current selection, then yanking it into
find-file, as when using:
While that works great, I wanted to make it into a command if possible, so I tried and came up with this so far:
(define-advice kill-ring-save (:around (old-fun &rest args) highlight) "Save the text selection and keep the selection highlight." (let (deactivate-mark) (apply old-fun args))) (defun find-file-region () (interactive) (execute-extended-command nil "kill-ring-save" nil) (call-interactively 'find-file) (yank nil))
Now, I'm using this particular
kill-ring-save function, mostly because I found it work better than the default one, but that's just what I noticed in my workflow. And also because i didn't know how to use the default one in this particular endeavor
So this doesn't obviously work, my guess being is that it doesn't run
yank after running
find-filebut since it require a filename and doesn't just "open with current directory of the buffer/file" like it usually do if used in the keybinding, that didn't work either.
(execute-extended-command nil "find-file" nil)but it did the same thing as far as I'm aware (that is, it didn't work either).
How could I pass the current selection/region (from
find-file and open the file whether it exists or not? (since usually, I recall
find-file creates the file if it doesn't exist, which is what I want too).
Don't really care if it's done interactively or in the background, as I just did that to tinker around and see if it'll work.