[Top][All Lists]

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

Re: repeat

From: Emanuel Berg
Subject: Re: repeat
Date: Fri, 19 Nov 2021 15:29:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

J.P. wrote:

> I agree that more easily recalling previously sent input
> would improve interactions with bots and services. But what
> about something more general, like commands resembling
>   previous-matching-history-element
>   next-matching-history-element
> and/or
>   previous-complete-history-element
>   next-complete-history-element
> from simple.el?
> Folks are already used to these interfaces, and many analogs
> exist across the Emacs universe and without as well (think
> readline's reverse-search-history and
> history-search-backward, for example).

You mean like this?

;;; -*- lexical-binding: t -*-
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/erc/erc-misc.el
;;;   https://dataswamp.org/~incal/emacs-init/erc/erc-misc.el

(require 'erc)
(require 'erc-ring)

;; improved by Felix Dietrich
(defun erc-cmd-R (&optional n)
  "Resend the most recent or Nth `erc' message/command.
The most recent message, the default, has index N = 0."
  (let ((num (or (and n (string-to-number n)) 0)))
    (if (and erc-input-ring
             (< (1+ num) (ring-length erc-input-ring)) )
          (ring-remove erc-input-ring 0)
          (erc-send-input (ring-ref erc-input-ring num))
          (ring-remove erc-input-ring 0) )
      (message "No data") )))

underground experts united

reply via email to

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