CMB / edbrowse

A command-line editor and web browser.
Other
345 stars 31 forks source link

use buffer contents as filename? #52

Open hallyn opened 5 years ago

hallyn commented 5 years ago

Hi,

I'm sorry, this is probably a FAQ, but I've several times searched through the docs and failed to find the answer.

I'd like to edit an empty buffer, write the filename of buffer 1 to it, edit that filename, then use that new path in an edbrowse command (r into a new buffer or w another buffer to the path).

Is there some variable substituion I can do in the command to do that?

eklhad commented 5 years ago

Hmm - seems like there are two questions here, neither of them trivial, though somewhat solvable if you stand on your head.

Getting ahold of the file name.

Say the file name of interest is on buffer 1 and you want to work within buffer 5. Assuming you are in session 1, you could do this.

A 2,$d s/'>$// s/^.*?'// w5 ^ e5

Now you are in session 5 with the file name from session 1. Obviously such things should be scripted if you do them often.

The next part is harder. Using that filename for something. There is a macro but only on shell escapes. Say you have modified the filename in some way and want to read it into buffer 4. This is awkward but here goes. I use quotes in case the file name has spaces or weird characters.

!ln -s "'." /tmp/foo e4 r /tmp/foo e5 !rm /tmp/foo

If you put it all together you probably don't need session 5 at all.

Karl Dahlke

hallyn commented 5 years ago

Thanks! 'A' is certainly interesting. It doesn't seem to be in the userguide?

It looks like in your version of edbrowse the filename must be in quotes when you do 'A'? But mine is not, so

s/'>$//
s/^.*?'//

Both fail. I can just skip the ' , but am curious about the difference.

hallyn commented 5 years ago

(ah, 'A' in my version only works in browse mode; it worked in my first attempt because i happened to be looking at /usr/share/doc/edbrowse/usersguide.html)

eklhad commented 5 years ago

A is described in Web And Email Addresses, and has been there since the very first perl version, but it has evolved over the years. It was originally designed to create bookmarks, in a bookmark file. Or "save to favorites" if you speak windows. In that sense it may have been a "browse" command, but became more general in, er um, I don't know, some version. The current version is 3.7.6. You might want to git clone and run the latest. Or if you don't want to tackle building edbrowse from source, which is not trivial, there are some statics on edbrowse.org, 3.7.5.1 I think, which is pretty close to current.

Quoting the filename was more recent, for safety, in case the file name has spaces or some such, Though it is url escaped so maybe I don't need to do that but I do it anyways.

Karl Dahlke