unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: shell-CLI for Emacs
Date: Sat, 24 Aug 2013 05:30:47 +0200	[thread overview]
Message-ID: <87zjs7bw8v.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:

> Maybe you can play w/ ‘call-interactively’ and
> ‘unread-command-events’.  Split the line as before but instead
> of ‘apply’ing the command to the args, push the args (character
> by character, in reverse order) onto ‘unread-command-events’,
> preceding each arg (set) with ‘C-j’ (newline).

Yes... that was a good idea. Impressive to say the least.

(require 'cl)
(defvar *ps* " $> ")

(defun string-to-cmd (str)
  (interactive (list (read-string *ps*)))
  (let*((cmd-and-args (split-string str " "))
        (cmd  (read (car cmd-and-args)))
        (args (cdr cmd-and-args)))
    (dolist (arg (nreverse args))
      (push 10 unread-command-events)
      (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)

Works for your zow test function, 'man emacs', and you don't have
to rewrite replace-string.

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


  parent reply	other threads:[~2013-08-24  3:30 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 [this message]
2013-08-26  0:56     ` Emanuel Berg
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87zjs7bw8v.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).