From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Reuse frame with emacsclient and/or use shell aliases when finding files Date: Sat, 31 May 2014 13:21:34 +0200 Message-ID: <87egzaqjlt.fsf@zigzag.favinet> References: <06de416b-9d9d-4e86-bc41-f6b9a06404f4@googlegroups.com> <723a5906-bae9-4db0-8c74-763712cc1410@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1401535145 15262 80.91.229.3 (31 May 2014 11:19:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 31 May 2014 11:19:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 31 13:18:58 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WqhJR-0007H4-Qp for geh-help-gnu-emacs@m.gmane.org; Sat, 31 May 2014 13:18:58 +0200 Original-Received: from localhost ([::1]:58930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqhJR-0000TL-03 for geh-help-gnu-emacs@m.gmane.org; Sat, 31 May 2014 07:18:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqhJ4-0000JO-KS for help-gnu-emacs@gnu.org; Sat, 31 May 2014 07:18:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqhIv-0005Hk-D0 for help-gnu-emacs@gnu.org; Sat, 31 May 2014 07:18:34 -0400 Original-Received: from smtp209.alice.it ([82.57.200.105]:63789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqhIu-0005Gr-S4 for help-gnu-emacs@gnu.org; Sat, 31 May 2014 07:18:25 -0400 Original-Received: from zigzag.favinet (79.51.71.61) by smtp209.alice.it (8.6.060.28) id 52443BB02B241AC3 for help-gnu-emacs@gnu.org; Sat, 31 May 2014 13:18:23 +0200 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1WqhM9-0007Mr-6B for help-gnu-emacs@gnu.org; Sat, 31 May 2014 13:21:45 +0200 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <723a5906-bae9-4db0-8c74-763712cc1410@googlegroups.com> (Jacob Gerlach's message of "Fri, 30 May 2014 18:57:19 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.105 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97975 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain () Jacob Gerlach () 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: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=.directory-env-vars Content-Transfer-Encoding: quoted-printable ;;; -*- emacs-lisp -*- ;;; comments start with ";" ;;; lines of form "- VAR" clear env var VAR ;;; lines of form "VAR VALUE" set env var VAR to VALUE ;; clear =2D OLDPWD =2D PWD ;; set A ~/build/GNU/alive D ~/build/tastiera-dura G ~/build/GNU GG ~/build/GNU/GG I ~/build/ixin L ~/other/linux-2.6.32.3 P ~/build/MISC/xorg/xcb/proto R ~/build/GNU/rcs RC ~/build/GNU/rcs-cov S ~/build/snuggle T ~/build/thud W ~/build/guile-www XS ~/build/MISC/xorg/lib/libX11/src b ~/build c ~/build/cmod-play cel ~/codebits/elisp cs ~/codebits/scheme d ~/build/sdl-demos dw ~/build/GNU/libredwg e ~/build/GNU/emacs/trunk edb ~/build/edb ee ~/build/GNU/serveez eel ~/build/GNU/serveez/src/libserveez eg ~/build/GNU/e el ~/build/GNU/emacs/trunk/lisp et ~/build/etrack g ~/build/u/g14 ge ~/build/GNU/G/18 gg ~/build/guile-gdbm gl ~/build/GNU/gnulib glug ~/build/www.glug.org go ~/build/GNU/elpa/packages/gnugo gx ~/build/guile-baux h ~/build/u/h hjh ~/build/gnuvola/software/guile/hjh i ~/build/u/g14/ice-9 lq ~/build/u/g14/libguile/quasi m ~/build/mixp ma ~/build/machiavelli o ~/other pe ~/build/pe pel ~/build/pe/lisp pg ~/build/guile-pg pi ~/build/pifi r ~/build/rpx/src rp ~/build/MISC/ratpoison sc ~/build/silenzio-cubico sdl ~/build/GNU/guile-sdl sr ~/etc/html/srfi-stash sw ~/build/gnuvola/software swig ~/build/MISC/swig td ~/build/ttn-do u ~/build/sgf-utils uio ~/build/guile-uio v ~/build/gnuvola w ~/build/wikid ;;; .directory-env-vars ends here --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=jamenv.el Content-Transfer-Encoding: quoted-printable ;;; jamenv.el ;;; ;;; Copyright (C) 2002, 2003, 2004, 2007, 2008 Thien-Thi Nguyen ;;; ;;; This file is part of ttn's personal elisp library, released under ;;; the terms of the GNU General Public License as published by the ;;; Free Software Foundation; either version 3, or (at your option) any ;;; later version. There is NO WARRANTY. See file COPYING for details. ;;; Description: Function to clear and set env vars. (require 'map-table) ;;;###autoload (defun jamenv (clear set) "Clear env vars in CLEAR and set env vars in SET. CLEAR is a list of symbols. SET is a list of symbols, alternating name and value, name first, similar to a plist." (mapc 'setenv (mapcar 'symbol-name clear)) (map-table-2col (lambda (varsym valsym) (setenv (symbol-name varsym) (symbol-name valsym))) set)) ;;;###autoload (defun jamenv-buffer () "Run `jamenv' on current-buffer." (interactive) (save-excursion (goto-char (point-min)) (let (clear set) (ignore-errors (while t (let ((a (read (current-buffer))) (b (read (current-buffer)))) (if (eq '- a) (setq clear (cons b clear)) (setq set (cons b (cons a set))))))) (jamenv (reverse clear) (reverse set)) (message "%s cleared, %s set" (length clear) (length set))))) ;;;###autoload (defun jamenv-from-file (file) "Read FILE and call `jamenv' on its contents. Lines beginning with \";\" are comments. Lines of the form \"- VAR\" mean to clear env var VAR. Lines of the form \"VAR VAL\" mean to set env var VAR to value VAL." (interactive "fDo `jamenv' on file: ") (with-temp-buffer (insert-file-contents file) (jamenv-buffer))) (provide 'jamenv) ;;;------------------------------------------------------------------------= --- ;;; jamenv.el ends here --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable and type (for example) =E2=80=98C-x C-f $go/gnugo.el=E2=80=99 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 =E2=80=98M-x compile=E2=80=99 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\")'. =20 For example, if (getenv \"hack\") =3D> \"~/build/hack\", then (rewrite-shell-command-w/cd \"$hack.b ; echo $hack\") =3D> \"cd ~/build/hack.b ; echo $hack\" =20 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 acti= vate) "Replace COMMAND using `rewrite-shell-command-w/cd'." (ad-set-arg 0 (rewrite-shell-command-w/cd (ad-get-arg 0)))) and bind =E2=80=98M-m=E2=80=99 to =E2=80=98compile=E2=80=99, 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 =E2=80=98default-directory=E2=80=99 (from current buffer) is at =E2=80=98M-m=E2=80=99 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... =2D-=20 Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) =3D> nil --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlOJu0IACgkQZwMiJEyAdQIKTwCgn2LsiyF0p9CF3U0JY4cXBAud VRIAoJr6jpar7HrW17BvKRcOICTlwbEP =yv19 -----END PGP SIGNATURE----- --==-=-=--