emacs-erc
[Top][All Lists]
Advanced

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

Re: erc-element.el


From: Emanuel Berg
Subject: Re: erc-element.el
Date: Thu, 17 Feb 2022 12:19:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

J.P. wrote:

> I agree that the behavior demonstrated by these commands is
> preferable to what's currently available from
> `erc-button-{previous,next}', namely, erroring at the bounds
> and being unresponsive at the prompt.

Ikr?

> If the latter constitutes a bug, then would it be
> responsible to change the existing commands rather than add
> new ones?
>
> For non-interactive use, I vote no, because third-party code
> may rely on that behavior, specifically those aspects you
> find fault with. But what about applying this exclusively to
> interactive invocations? That may still be unwise because of
> the added complexity and possible confusion arising from the
> disparity. But I suppose some discussion regarding that
> would be warranted.

For interactive use, they could be called from the buttons
function and placed in the same file. Interestingly, the
implementation of these functions use the button functions ...

I wrote a better version just now that cycles the buttons and
prompt both on next and on prev.

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   https://dataswamp.org/~incal/emacs-init/erc/erc-element.el

(require 'erc)
(require 'erc-button)

(defun erc-at-prompt-p ()
  (let ((pos (marker-position erc-insert-marker)))
    (<= pos (point)) ))

(defun erc-element-next (&optional prev)
  (interactive "P")
  (when (erc-at-prompt-p)
    (goto-char (point-min)) )
  (condition-case nil
      (if prev
          (erc-button-previous)
        (erc-button-next) )
    (error (progn
             (goto-char (point-max))
             (when prev
               (erc-bol) )))))

(defun erc-element-prev ()
  (interactive)
  (let ((beg (point)))
    (erc-element-next t)
    (when (= (point) beg)
      (forward-line 0)
      (backward-char)
      (erc-element-next t) )))

(provide 'erc-element)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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