unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: repeat the last single shell command
Date: Thu, 18 Jul 2013 15:24:39 +0200	[thread overview]
Message-ID: <874nbst2zs.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: 87fvvcxcn1.fsf@yahoo.fr

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

>> Yes, it works, but that's pretty much the same of M-p. I'd like to
>> know if there's some shortcut, let's say like M-!!, to immediatly
>> repeat the last command. Otherwise I have to define a function.
>
> I think M-! M-p RET is simple enough, but you can do this:
>
> (defun yf/last-history-element-and-exit ()
>   "Select the last history element."
>   (interactive)
>   (goto-history-element 1)
>   (exit-minibuffer))
> (define-key minibuffer-local-shell-command-map (kbd "!") 'yf/last-history-element-and-exit)

Nice idea, but then you can't enter ! anymore in a shell command.

Here's an improved version that does handle ! (or whatever char you've
bound `yf/last-history-element-and-exit' to) only special if it's the
first char entered at the prompt.

--8<---------------cut here---------------start------------->8---
(defun yf/last-history-element-and-exit ()
  "Select the last history element."
  (interactive)
  (if (not (= (1+ (minibuffer-prompt-width)) (point)))
      (self-insert-command 1)
    (goto-history-element 1)
    (exit-minibuffer)))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




  reply	other threads:[~2013-07-18 13:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18  9:00 repeat the last single shell command Luca Ferrari
     [not found] ` <CAKcmqqyD8e2bX99NHMKG0h+fdF=U66mBsJ-W=4ygtmvJgNGaGA@mail.gmail.com>
2013-07-18  9:55   ` Luca Ferrari
2013-07-18 11:35     ` Suvayu Ali
2013-07-18 12:34       ` Luca Ferrari
2013-07-18 12:42     ` Nicolas Richard
2013-07-18 13:24       ` Tassilo Horn [this message]
2013-07-18 13:52         ` Nicolas Richard
2013-07-18 14:18           ` Tassilo Horn
2013-07-18 16:08             ` Yuri Khan
     [not found]             ` <mailman.1343.1374163702.12400.help-gnu-emacs@gnu.org>
2013-07-18 19:07               ` Barry Margolin
     [not found]       ` <mailman.1333.1374153910.12400.help-gnu-emacs@gnu.org>
2013-07-18 14:45         ` Barry Margolin
2013-07-18 10:33 ` Peter Dyballa
2013-07-18 13:11 ` Tassilo Horn
2013-07-18 14:01   ` Luca Ferrari
2013-07-18 14:12   ` Nicolas Richard
2013-07-18 14:22     ` Tassilo Horn

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=874nbst2zs.fsf@thinkpad.tsdh.de \
    --to=tsdh@gnu.org \
    --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).