![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
...so says one of Murphy's Laws of Combat. As it turns out, "usually" doesn't mean "always."
For the past 6 months, I've been using something called Org within the Windows version of Emacs, mostly to keep track of assignments, invoices, and payments. Each job "lives" in its own headline entry as part of a hierarchical outline under its respective client. Each job headline entry has subordinate headlines for the documents that are part of a job, as well as the odd note, disambiguation reminder, and what have you.
Changing job status—say, from ASSIGNED (what it means) to BILLQ (in the queue to be invoiced)—is a three-keystroke operation. Assigning a deadline typically involves two keystrokes and a mouse click. Pulling up a view of the next week's activities involves two keystrokes. In the grand Emacs tradition, everything is done in text mode, and the editor takes care of displaying what's needed.
One neat feature is the ability to create links to folders that, when clicked, open an appropriate Explorer window. For example, typing
One thing though, has bothered me, and that's the repetitive nature of creating links to the folders where my assignment files are.
By way of background, my standard folder name format for jobs is
In the end, what I end up with when I create links to assignment folders is this:
It was a situation that cried out for a programmatic solution, except that—strangely enough—Emacs would not let me.
The reason? The backslash character. In Windows, the backslash is a normal part of a string describing a path. In Emacs, which is imbued with strong *nix traditions, the backslash has a "special power." The presence of a backslash character in a string tells Emacs to ignore the "special power" (if any) of the next character in the string (a process called "escaping").
For example, if the character following a backslash is another backslash, the second backslash would be treated like a backslash with no special powers, i.e., just a plain old backslash.
Still with me? (Full marks if you are, because I'm getting a little groggy trying to keep the explanation clear, myself.)
In any event, in order to do anything useful with a backslash-laden Windows path in Emacs (using Emacs Lisp), the path string would really have to look like:
Autohotkey to the rescue!
Once started, Autohotkey works pretty much everywhere within one's system. It has loads of features, including all sorts of string manipulation functions.
Basically, once I figured out what had to be done, I was able to write the code for an Autohotkey macro that served my purpose in about 3 lines (the actual macro is a couple of lines longer because I've already added some bells and whistles to what's done. The result is perhaps not as "elegant" as being able to say one did it all in Emacs Lisp, but it works just as well. And that, fellow sufferers, is what counts!
It's been a busy day. I've had to use the macro four times already!
Cheers...
For the past 6 months, I've been using something called Org within the Windows version of Emacs, mostly to keep track of assignments, invoices, and payments. Each job "lives" in its own headline entry as part of a hierarchical outline under its respective client. Each job headline entry has subordinate headlines for the documents that are part of a job, as well as the odd note, disambiguation reminder, and what have you.
Changing job status—say, from ASSIGNED (what it means) to BILLQ (in the queue to be invoiced)—is a three-keystroke operation. Assigning a deadline typically involves two keystrokes and a mouse click. Pulling up a view of the next week's activities involves two keystrokes. In the grand Emacs tradition, everything is done in text mode, and the editor takes care of displaying what's needed.
One neat feature is the ability to create links to folders that, when clicked, open an appropriate Explorer window. For example, typing
[[c:\foo\bar\bat][Baseball job]]will create a clickable link named "Baseball job". This is pretty important to me, as quite a bit of work I do requires me to go back and review previous documents, and, of course, being an editor, Emacs has a pretty good search capability, so over the past 6 months or so, I've been able to create a pretty good searchable mass of data about the documents I've been working on.
One thing though, has bothered me, and that's the repetitive nature of creating links to the folders where my assignment files are.
By way of background, my standard folder name format for jobs is
YYMMDD-TLC-Slugwhere YYMMDD is a six-digit date (yesterday was 120807, for example; tomorrow will be 120809), TLC is a Three-Letter Code for the client, and Slug is a text string (such as the client's job number and/or a word from the document title, such as "Hemodynamics") that identifies the job.
In the end, what I end up with when I create links to assignment folders is this:
[C:\Documents\2012\YYMMDD-TLC-Slug][YYMMDD-CLI-Slug]]Up until yesterday, this entailed copying the path to the job folder, Alt-Tabbing to Emacs, and then pasting the copied path twice, deleting a chunk of the pasted string after the second paste operation to leave behind just the job folder name.
It was a situation that cried out for a programmatic solution, except that—strangely enough—Emacs would not let me.
The reason? The backslash character. In Windows, the backslash is a normal part of a string describing a path. In Emacs, which is imbued with strong *nix traditions, the backslash has a "special power." The presence of a backslash character in a string tells Emacs to ignore the "special power" (if any) of the next character in the string (a process called "escaping").
For example, if the character following a backslash is another backslash, the second backslash would be treated like a backslash with no special powers, i.e., just a plain old backslash.
Still with me? (Full marks if you are, because I'm getting a little groggy trying to keep the explanation clear, myself.)
In any event, in order to do anything useful with a backslash-laden Windows path in Emacs (using Emacs Lisp), the path string would really have to look like:
C:\\foo\\bar\\batThat said, this could only happen (as far as I can tell) if I were to stop and edit the string copied to my Clipboard, which would involve more trouble than the whole exercise is worth.
Autohotkey to the rescue!
Once started, Autohotkey works pretty much everywhere within one's system. It has loads of features, including all sorts of string manipulation functions.
Basically, once I figured out what had to be done, I was able to write the code for an Autohotkey macro that served my purpose in about 3 lines (the actual macro is a couple of lines longer because I've already added some bells and whistles to what's done. The result is perhaps not as "elegant" as being able to say one did it all in Emacs Lisp, but it works just as well. And that, fellow sufferers, is what counts!
It's been a busy day. I've had to use the macro four times already!
Cheers...