help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell-CLI for Emacs


From: Emanuel Berg
Subject: Re: shell-CLI for Emacs
Date: Sat, 24 Aug 2013 05:30:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]