all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Reuse frame with emacsclient and/or use shell aliases when finding files
Date: Sat, 31 May 2014 13:21:34 +0200	[thread overview]
Message-ID: <87egzaqjlt.fsf@zigzag.favinet> (raw)
In-Reply-To: <723a5906-bae9-4db0-8c74-763712cc1410@googlegroups.com> (Jacob Gerlach's message of "Fri, 30 May 2014 18:57:19 -0700 (PDT)")


[-- Attachment #1.1: Type: text/plain, Size: 342 bytes --]

() Jacob Gerlach <jacobgerlach@gmail.com>
() Fri, 30 May 2014 18:57:19 -0700 (PDT)

   I wonder if I could come up with some utility
   function to read in bash aliases and create the
   associated dired bookmarks when I start emacs.

Probably yes, if you learn a small bit of Emacs Lisp.
Personally, i define an env var for each directory:


[-- Attachment #1.2: .directory-env-vars --]
[-- Type: application/emacs-lisp, Size: 2244 bytes --]

[-- Attachment #1.3: jamenv.el --]
[-- Type: application/emacs-lisp, Size: 1911 bytes --]

[-- Attachment #1.4: Type: text/plain, Size: 2283 bytes --]


and type (for example) ‘C-x C-f $go/gnugo.el’ to visit
/home/ttn/build/GNU/elpa/packages/gnugo/gnugo.el.

Recent Emacs versions can do completion, and even on
the env vars!  (I marvel at this, taken aback by the
mega-cycles burned for such banalities -- i guess i
prefer a more lizard-like less-electric lifestyle...
[insert more curmudgeonly harumphing] here.)

The "scads of short env vars" approach has, over the
years, tickled bugs in various tools that presume such
env vars are not set, which was annoying at the time,
but good for all (me and tools) over the long run,
once the tools' authors made them more mindful.

I also instrument ‘M-x compile’ like so:

 (defun rewrite-shell-command-w/cd (string)
   "If STRING begins w/ \"$foo\", return a new string.
 In the new string, the \"$foo\" is replaced with \"cd $foo\", and
 furthermore \"$foo\" is replaced with the value of `(getenv \"foo\")'.
 
 For example, if (getenv \"hack\") => \"~/build/hack\", then
   (rewrite-shell-command-w/cd \"$hack.b ; echo $hack\")
   => \"cd ~/build/hack.b ; echo $hack\"
 
 For other values of STRING, simply return it."
   (save-match-data
     (if (string-match "^[$]\\([a-zA-Z_]+\\)" string)
         (replace-match (concat "cd " (getenv (match-string 1 string)))
                        t t string)
       string)))

 (defadvice compilation-start (before rewrite-compilation-command-w/cd activate)
  "Replace COMMAND using `rewrite-shell-command-w/cd'."
  (ad-set-arg 0 (rewrite-shell-command-w/cd (ad-get-arg 0))))

and bind ‘M-m’ to ‘compile’, such that (for example)

 M-m $go ; git remote update RET

invokes the "git remote update" command in directory
/home/ttn/build/GNU/elpa/packages/gnugo, no matter
what the ‘default-directory’ (from current buffer) is
at ‘M-m’ time.  This is a small step towards the yet-
unrealized ideal of having the env var expanded in the
command, itself, which involves phasing complications
for the expansion of "~", primarily.  Maybe Some Day...

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2014-05-31 11:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 21:56 Reuse frame with emacsclient and/or use shell aliases when finding files Jacob Gerlach
2014-05-30 22:13 ` Thorsten Jolitz
2014-05-30 22:47 ` Robert Thorpe
     [not found] ` <mailman.2576.1401490089.1147.help-gnu-emacs@gnu.org>
2014-05-31  1:57   ` Jacob Gerlach
2014-05-31 11:21     ` Thien-Thi Nguyen [this message]
2014-05-31 11:22     ` Robert Thorpe
     [not found]     ` <mailman.2614.1401535376.1147.help-gnu-emacs@gnu.org>
2014-05-31 14:16       ` Jacob Gerlach
2014-05-31 15:49         ` Robert Thorpe
2014-05-31 11:41 ` Thorsten Jolitz
2014-05-31 13:39   ` Robert Thorpe
2014-05-31 15:54     ` Thorsten Jolitz
2014-06-01 23:42 ` lee
     [not found] ` <mailman.2724.1401666174.1147.help-gnu-emacs@gnu.org>
2014-06-02  1:10   ` Jacob Gerlach
     [not found] ` <mailman.2618.1401536506.1147.help-gnu-emacs@gnu.org>
2014-06-06  8:35   ` Hans BKK
2014-06-06 11:31 ` Alexander Baier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egzaqjlt.fsf@zigzag.favinet \
    --to=ttn@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.