Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How Insert Link in a Text File?

95 views
Skip to first unread message

BobD

unread,
Oct 31, 2021, 5:25:32 PM10/31/21
to
Using Windows 7 64-bit
Emacs 27.1

How do I place a link in a text file?

I'd like to put some text in a text file that links to a point in another file, so that when I enter designated keystrokes on the text, emacs moves to the linked point.

Ben Bacarisse

unread,
Oct 31, 2021, 5:52:05 PM10/31/21
to
This is going to be one of those answers that posters hate. Sorry! I
can't answer, but I can help you ask a better question.

The trouble is that "text file" is too vague. An HTML document is a
text file. The way you put a link into such a text file is using <a>
elements and Emacs can follow the links quite happily. But I am sure
you don't want that...

At the other end of the scale is a text file with no internal syntax or
rules. In this case you's have to make it all up yourself. You'd have
to pick the syntax for a link and tell Emacs what to do with it. That's
too much work. (It's possible there is an Emacs mode I don't know about
that already does this. If so, it may be the perfect fit for you.)

In the middle is org mode. This is an Emacs mode to edit files that
readable as plain text outside org mode (and by other editors or
example) but have a lot of structure: sections, sub-sections, links,
tables and so on. I like org mode, but it may not help you one bit if
someone else is dictating the text file's format.

Finally, for some tasks, what you want may be bookmarks. Emacs
bookmarks use an external database (just a file) of marked locations in
files. You can move from bookmark to bookmark by issuing simple
commands. (Disclaimer: I've never used them. I got the feeling they
were not intuitive one time and never tried again!)

--
Ben.

BobD

unread,
Oct 31, 2021, 7:04:59 PM10/31/21
to
On Sunday, October 31, 2021 at 5:52:05 PM UTC-4, Ben Bacarisse wrote:
Thanks for answering!
I wish to insert links into plain text files, i.e. flat files with no structural meta-content, so that I can tell emacs to go to the link's target.
I know of org mode, but it seems much, much more than I need.
A bookmark embedded in a file, instead of going through the menu, would be good.

Gene

unread,
Nov 3, 2021, 3:00:51 PM11/3/21
to
As Ben has already responded with a watered down version my original, covert response(s) and participation in this group is rather low, I'll opt for an oddly less precise overt response than Ben while attempting to further clarity on a gamut of topics, issues, and themes revealing a decidedly low love-of-wisdom as contrasted with a so-called `philosopher' as a lover-of-wisdom.

Neither `text' nor `file' nor `text file' have any semantic/meaning in any Chomskian deep-structural way; `text' ALWAYS amounts to mere surface structure in Noam's distinction.
But more importantly, the Behaviorists -- who have been thrown out as babies along with the bath water and wash-tub ring, by NF/idealist flakes and priestesses in the secular religion called `Clinical Psychology' in favor of flaky Rogerian `humanism' (which can be simulated with Eliza-cum-Doctor as an emacs `game') -- would regard `text' as found in `text files' as mere STIMULI.
And as such, textual stimuli regarded as if concrete quasi-static `things' may be regarded as the proverbial tree falling in the forest with or without a rat in a Skinner Box there to witness either phenomena or epiphenomena if or when said tree falls.

Enter Emacs modes.
Emacs modes operationally ARE responders-to-stimuli.
When a buffer containing text qua text is `viewed' -- by YOU as the mode code responses as if a rat in a Skinner box -- by `fundamental mode' both you and the mode are (mal)functioning like a village idiot contrasted with `smarter modes' capable of nuance and deep-structural awareness of MEANING ... with one type of meaning being `reference' wherein text is not a thing in itself, but rather a reference to something else: an indexical such as `this', `that', `these', `those'.

But what might an experiment reveal?
What if you want text qua TEXT which functions-as-if referential links ... but we don't want to encode the text in any special way, so much as we want an emacs mode to DWIM?
If what one MEANS to have happen in response to text-as-if-links is to have a link followed in either emacs eww or an external browser then the slickest way to manifest this overt behavior is to put the right animal in the Skinner Box.

I routinely past `text' created by browser addon which faithfully creates a text file containing all the URLs corresponding to open tabs in said browser.
Were I to experience your question in the first person I would set out to solve the as-experienced problem by firstly tweeking the text via some encoding scheme, then using elisp to decode and DWIM as per encoded wishes.
As I've been (mis)using emacs for over a quarter century and have dabbled with an assortment of libraries and packages, I do the following: upon pasting the list of URLs attained from `Export Tab' or such into an emacs buffer I perform a save-as operation in which I conjure up a file name which I apply a `.org' extension. Then I close the file and dissociate for a bit ... perhaps by M-x doctor.

I tell emacs' doctor all my problems ...how I hate the haters, resent the reenters, love the well-intentioned fuck-ups (EG WIFU) secular humanists -- or Big Brother, where different -- who have leveraged virtue off poor ol' B.F.Skinner as one of those dowdy, dumpy old Straight White Males ... then recall the lyric to the Steely Dan song `Any Major Dude' which asserts that `any 'mount of earth that falls apart falls together again'.
Recalling that the definition of insanity is doing the same thing over and over again and expecting different results, I find-file on the `text' file I mistakenly named `.org' instead of `.txt' in anticipation of resuming my quest for an encoding scheme and some sort of DWIM magic can be made to have magical thinking manifest as if I were a delicate snowflake entitled to such White Privilege -- regardless of which 1-bit of resolution color-as-if-RACE socio-impolitical category-cum-`identity' I may be beheld as-if as per both Identity ImPolitics-as-Usual and Categorical Discrimination -- oops, I mean -- Identity Politics.

But because I misnamed my `text', it is presented to the org-mode rat in the Skinner Box WEIRD THINGS HAPPEN.
The `text' has highlighted regions which reveal that I can `click' on them.
And when I DO click on one of them ... what happens?

Whoa is me!
Chomskian surface structural text qua TEXT is transmogrified into deep structural DWIM via the magic of Behaviorism.
The org-mode rat in a skinner box behaves like some sort of Sorcerer's Apprentice.

Now lemme think ... how can I encode `links' in a text file ... then get emacs to decode my clever new encoding scheme?

Cheers!
Gene

P.S. Yes, org-mode allows one to link to other files and text in other files as well as URLs
The take away message here is to NOT re-invent the wheel; your desire is not so exotic that plenty of other geeks have not had it and employed wishful thinking to do something about it.
Check out eev.el -- https://html.duckduckgo.com/html?q=eev.el -- to see what Eduardo Ochs' response to this recurring whim to have text-as-if-links' Do-what-I-Mean ... though perhaps after paying homage to Ted Nelson as the progenitor of hypertext as the foundation for hypertext links.

Gene

unread,
Nov 3, 2021, 3:17:31 PM11/3/21
to
On Sunday, October 31, 2021 at 7:04:59 PM UTC-4, BobD wrote:

> I know of org mode, but it seems much, much more than I need.

Lemme guess.
Are you one of those guys who won't wear a wrist watch because it's only a single-function gadget, but will purchase a budget no-contract flipfone, not use it as a flipfone, but only a watch then refuse to use it for anything other than a time piece ... such as an FM radio?

org-mode has been Built-in to emacs for how many releases now?
The emacsen are swiss army chain saws.
All the blades are still there whether you use them or not.
Though org-mode may SEEM `more than you need' how much effort does it take to toggle a mode?
That's what changes modes is analogous to ... applying a new blade to your `text file' whittling project.

There is a package which allows one to use org-mode style links OUTSIDE of org-mode.
That's how popular org-mode's link system is.

As it's already been done, you might want to rummage through the elisp code as a proof-of-concept to see EXACTLY how it already has been done.
Then you can either opt to re-use the wheel, or re-invent a regular polygon with sufficient side count to approximate a wheel for your own use.


> A bookmark embedded in a file, instead of going through the menu, would be good.

One can save `variables' with every file, where bookmarks are a type of variable.

Also, there is an annotate package which allows one to annotate a file without changing it's contents.
Thus the annotation file can contain links related to the content one is annotating.

Cheers!
Gene
0 new messages