From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: shell-CLI for Emacs
Date: Mon, 26 Aug 2013 02:56:35 +0200 [thread overview]
Message-ID: <8738px9smb.fsf@nl106-137-194.student.uu.se> (raw)
In-Reply-To: mailman.670.1377304488.10748.help-gnu-emacs@gnu.org
Thien-Thi Nguyen <ttn@gnu.org> writes:
> Of course, this technique loses w/ certain (stealthy)
> ‘interactive’ specs ‘interactive’ specs, regions ...
replace-string works with and without a region, when I did exactly
as you told me. But perhaps there is more to regions?
> stateful (history var) defaults
What's that? :)
> args that include a space
I got that solved. Now,
replace-string 'Hello all!' 'Dear all,'
works.
The code [1] got somewhat complicated...
> That's the primary benefit of all DWIM hacking, after all, for
> both you and Emacs!
DWIM, is that what I'm doing? Why did you say that? I'm to read
the Wikipedia article tonight - never heard of it, but intuitively
I like it.
Some people take pride in memorizing and understanding complex
command, drawing oh's and ah's from the crowd: what wizardry! I
think that's just silly. In a nutshell, this is what my system
looks like:
add_dic () { sudo tar -xvjf $1 -C /usr/share/stardict/dic; }
That's why Captain Picard say "Engage!", and not "Set the
thrusters to blaha blaha, align the ship to etc. etc., then..."
(Perhaps that's unrelated to DWIM.)
[1]
(require 'cl)
(defvar *ps* " $> ")
(defun string-to-cmd (str)
(interactive (list (read-string *ps*)))
(let*((cmd (read (car (split-string str " "))))
(args (cdr (make-arg-list (string-to-list str)))) )
(dolist (arg (nreverse args))
(push 13 unread-command-events) ; 13 is RET
(dolist (n (reverse (string-to-list arg)))
(push n unread-command-events) ))
(call-interactively cmd) ))
(define-key (current-global-map) (kbd "M-i") 'string-to-cmd)
(defun make-arg-list (chars)
(interactive)
(if chars
(let ((WS 39) ; whitespace ( )
(SQM 32) ; quote (')
(c (car chars))
(cs (cdr chars)) )
(if (eq c WS) (make-word cs '() WS)
(if (eq c SQM) (make-arg-list cs)
(make-word chars '() SQM)) ))
'() ))
(defun make-word (chars wd sep)
(interactive)
(if chars
(let ((c (car chars))
(cs (cdr chars)))
(if (eq c sep) (cons wd (make-arg-list cs))
(make-word cs (append wd (list c)) sep)))
(list wd) ))
--
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573
next prev parent reply other threads:[~2013-08-26 0:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.664.1377295372.10748.help-gnu-emacs@gnu.org>
2013-08-23 22:42 ` shell-CLI for Emacs Emanuel Berg
2013-08-24 0:37 ` Thien-Thi Nguyen
[not found] ` <mailman.670.1377304488.10748.help-gnu-emacs@gnu.org>
2013-08-24 3:30 ` Emanuel Berg
2013-08-26 0:56 ` Emanuel Berg [this message]
2013-08-26 4:03 ` Yuri Khan
2013-08-26 5:38 ` Thien-Thi Nguyen
2013-08-23 22:02 Barry OReilly
-- strict thread matches above, loose matches on Subject: below --
2013-08-23 20:46 Emanuel Berg
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=8738px9smb.fsf@nl106-137-194.student.uu.se \
--to=embe8573@student.uu.se \
--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.