From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: shell-CLI for Emacs Date: Mon, 26 Aug 2013 02:56:35 +0200 Organization: Aioe.org NNTP Server Message-ID: <8738px9smb.fsf@nl106-137-194.student.uu.se> References: <87zjs8kozg.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1377478816 31709 80.91.229.3 (26 Aug 2013 01:00:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Aug 2013 01:00:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 26 03:00:19 2013 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 1VDlAH-00065u-JX for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Aug 2013 03:00:17 +0200 Original-Received: from localhost ([::1]:48267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDlAH-0005FI-6o for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Aug 2013 21:00:17 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 82 Original-NNTP-Posting-Host: FplVx5MqBzlFp1u9bZOXWQ.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:MqKQRP5M7xAI0lGUIvfbjFVQKQI= Original-Xref: usenet.stanford.edu gnu.emacs.help:200819 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:93086 Archived-At: Thien-Thi Nguyen 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