unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46339: 28.0.50; ERC likely bug with `erc-previous-command'
@ 2021-02-06  6:39 Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-08 11:07 ` J.P.
  0 siblings, 1 reply; 5+ messages in thread
From: Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-02-06  6:39 UTC (permalink / raw)
  To: 46339


In ERC, try type /n RET, then type abc and invoke
`erc-previous-command'

  erc-add-to-input-ring: Wrong type argument: erc-input, "abc"

what does that mean? `erc-next-command' works so a bug is
perhaps likely.


In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-10-23 built on ebih
Repository revision: 558065531beaaae78810508f267415c6953e8e47
Repository branch: master
System Description: Debian GNU/Linux bullseye/sid

Configured features:
XPM JPEG TIFF GIF PNG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBSELINUX GNUTLS FREETYPE HARFBUZZ ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  erc-list-mode: t
  erc-menu-mode: t
  erc-networks-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-netsplit-mode: t
  cursor-sensor-mode: t
  show-paren-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-autojoin-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  erc-scrolltobottom-mode: t
  gnus-undo-mode: t
  shell-dirtrack-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  transient-mark-mode: t

Load-path shadows:
~/.emacs.d/emacs-init/signal hides /home/incal/.emacs.d/elpa/signal-20160816.1438/signal
~/.emacs.d/lisp/abbrev hides /usr/local/share/emacs/28.0.50/lisp/abbrev

Features:
(make-mode cl-print shadow emacsbug eieio-opt speedbar ezimage
dframe shortdoc help-fns radix-tree mule-util w3m-symbol ffap
cus-edit cus-start cus-load erc-list erc-menu erc-networks
erc-track erc-netsplit cl-extra mailalias tabify mail-extr
gnus-async gnus-bcklg gnus-dup gnus-draft gnus-ml disp-table
cursor-sensor pop3 nndraft nnmh nnml gnutls network-stream nsm
gnus-agent nnvirtual nntp gnus-cache term/linux paren
nroff-mode css-mode sgml-mode imenu eww xdg url-queue mm-url
checkdoc lisp-mnt cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs message-my moggle
message-my-dynamic mail-to-many smtpmail sendmail xsel lpr
tramp-sh markdown-mode rx color noutline outline w3m-form
sh-script smie executable org-faces erc-match erc-button
bibtex t-mouse man tex-mode iterate-files issn-verify
isbn-verify pcase yank-my wrap-search w3m-unisearch w3m-search
spell-new ispell sort-my sort shell-cli revert-buffer-my
lisp-new ielm kill keys help-new debug backtrace help-mode
find-func apropos dired-x compile-my mode-line compile article
gnus-cite dl bookmarks w3m-bookmark em-hist em-pred esh-mode
quit gnus-my group group-summary gnus-srvr erc-my fill-new
erc-ring erc-pcomplete erc-join erc-fill erc-stamp erc-goodies
erc erc-backend pp erc-loaddefs gnus-score score-mode gnus-msg
gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum
shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus
dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
gnus-spec gnus-int gnus-range gnus-win message rmc puny rfc822
mml mml-sec epa derived epg epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums text-property-search mail-utils mm-util mail-prsvr
eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg
esh-module esh-groups esh-util edit tabs dired-my w3m-my
thingatpt w3m-tabs w3m-session w3m doc-view jka-compr
image-mode exif timezone w3m-hist w3m-fb bookmark-w3m w3m-ems
wid-edit w3m-favicon w3m-image tab-line w3m-proc w3m-util
time-my time-my-insert files-my tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat shell pcomplete comint
ansi-color ring parse-time iso8601 time-date ls-lisp
format-spec sudo-user-path find-command file-write-to
window-new search-regexp-in-files count get-search-string
caps-back easy-mmode buffer-menu switch-to-buffer super scroll
dired dired-loaddefs close buc switch-to-buffer-regexp
align-new my-string slime-autoloads w3m-load info package
easymenu browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars
seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode elisp-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet
lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads
dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 494971 68137)
 (symbols 48 32958 12)
 (strings 32 118948 12771)
 (string-bytes 1 3988654)
 (vectors 16 49273)
 (vector-slots 8 1318508 198821)
 (floats 8 492 600)
 (intervals 56 14095 350)
 (buffers 992 51))

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46339: 28.0.50; ERC likely bug with `erc-previous-command'
  2021-02-06  6:39 bug#46339: 28.0.50; ERC likely bug with `erc-previous-command' Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-02-08 11:07 ` J.P.
  2021-02-09 20:46   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: J.P. @ 2021-02-08 11:07 UTC (permalink / raw)
  To: 46339; +Cc: emacs-erc

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

Emanuel Berg <moasenwood@zoho.eu> writes:

> what does that mean? `erc-next-command' works so a bug is
> perhaps likely.

I think it's expecting an erc-input struct object, as passed by the hook
erc-pre-send-functions.

Would something like the following work?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Accept-string-argument-in-erc-add-to-input-ring.patch --]
[-- Type: text/x-patch, Size: 5396 bytes --]

From a805a4e507e19eb6c68fdd57ea7d8972b270aeb9 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Mon, 8 Feb 2021 02:34:18 -0800
Subject: [PATCH] Accept string argument in erc-add-to-input-ring

* lisp/erc/erc-ring.el: (erc-add-to-input-ring)
(erc-previous-command): Use existing API to grab input.
* test/lisp/erc/erc-tests.el: (erc-ring-previous-command)
See (bug#46339).
---
 lisp/erc/erc-ring.el       | 18 ++++++-----
 test/lisp/erc/erc-tests.el | 64 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/lisp/erc/erc-ring.el b/lisp/erc/erc-ring.el
index 71a9f8ef3da..028ab1eead8 100644
--- a/lisp/erc/erc-ring.el
+++ b/lisp/erc/erc-ring.el
@@ -69,10 +69,13 @@ erc-input-ring-setup
     (setq erc-input-ring (make-ring comint-input-ring-size)))
   (setq erc-input-ring-index nil))
 
-(defun erc-add-to-input-ring (state)
-  "Add string S to the input ring and reset history position."
+(defun erc-add-to-input-ring (state-or-string)
+  "Add STATE-OR-STRING to input ring and reset history position.
+STATE-OR-STRING should be a string or an erc-input object."
   (unless erc-input-ring (erc-input-ring-setup))
-  (ring-insert erc-input-ring (erc-input-string state))
+  (ring-insert erc-input-ring (if (erc-input-p state-or-string)
+                                  (erc-input-string state-or-string)
+                                state-or-string)) ; string
   (setq erc-input-ring-index nil))
 
 (defun erc-clear-input-ring ()
@@ -101,11 +104,10 @@ erc-previous-command
       ;; area, push it on the history ring before moving back through
       ;; the input history, so it will be there when we return to the
       ;; front.
-      (if (null erc-input-ring-index)
-          (when (> (point-max) erc-input-marker)
-            (erc-add-to-input-ring (buffer-substring erc-input-marker
-                                                     (point-max)))
-            (setq erc-input-ring-index 0)))
+      (when (and (null erc-input-ring-index)
+                 (> (point-max) erc-input-marker))
+        (erc-add-to-input-ring (erc-user-input))
+        (setq erc-input-ring-index 0))
 
       (setq erc-input-ring-index (if erc-input-ring-index
                                      (ring-plus1 erc-input-ring-index
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 26e14b98e91..d13397274aa 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -23,6 +23,7 @@
 
 (require 'ert)
 (require 'erc)
+(require 'erc-ring)
 
 (ert-deftest erc--read-time-period ()
   (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "")))
@@ -45,3 +46,66 @@ erc--read-time-period
 
   (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "1d")))
     (should (equal (erc--read-time-period "foo: ") 86400))))
+
+(ert-deftest erc-ring-previous-command-base-case ()
+  (ert-info ("Create ring when nonexistent and do nothing")
+    (let (erc-input-ring
+          erc-input-ring-index)
+      (erc-previous-command)
+      (should (ring-p erc-input-ring))
+      (should (zerop (ring-length erc-input-ring)))
+      (should-not erc-input-ring-index)))
+  (should-not erc-input-ring))
+
+(ert-deftest erc-ring-previous-command ()
+  (with-current-buffer (get-buffer-create "*#fake*")
+    (erc-mode)
+    (insert "\n\n")
+    (setq erc-input-marker (make-marker) ; these are all local
+          erc-insert-marker (make-marker)
+          erc-send-completed-hook nil)
+    (set-marker erc-insert-marker (point-max))
+    (erc-display-prompt)
+    (should (= (point) erc-input-marker))
+    (add-hook 'erc-pre-send-functions #'erc-add-to-input-ring nil t)
+    ;;
+    (cl-letf (((symbol-function 'erc-process-input-line)
+               (lambda (&rest _)
+                 (insert-before-markers
+                  (erc-display-message-highlight 'notice "echo: one\n"))))
+              ((symbol-function 'erc-command-no-process-p)
+               (lambda (&rest _) t)))
+      (ert-info ("Create ring, populate, recall")
+        (insert "/one")
+        (erc-send-current-line)
+        (should (ring-p erc-input-ring))
+        (should (zerop (ring-member erc-input-ring "/one"))) ; equal
+        (should (save-excursion (forward-line -1) (goto-char (point-at-bol))
+                                (looking-at-p "[*]+ echo: one")))
+        (should-not erc-input-ring-index)
+        (erc-bol)
+        (should (looking-at "$"))
+        (erc-previous-command)
+        (erc-bol)
+        (should (looking-at "/one"))
+        (should (zerop erc-input-ring-index)))
+      (ert-info ("Back to one")
+        (should (= (ring-length erc-input-ring) (1+ erc-input-ring-index)))
+        (erc-previous-command)
+        (should-not erc-input-ring-index)
+        (erc-bol)
+        (should (looking-at "$"))
+        (should (equal (ring-ref erc-input-ring 0) "/one")))
+      (ert-info ("Swap input after prompt with previous (#bug46339)")
+        (insert "abc")
+        (erc-previous-command)
+        (should (= 1 erc-input-ring-index))
+        (erc-bol)
+        (should (looking-at "/one"))
+        (should (equal (ring-ref erc-input-ring 0) "abc"))
+        (should (equal (ring-ref erc-input-ring 1) "/one"))
+        (erc-next-command)
+        (erc-bol)
+        (should (looking-at "abc")))))
+  (when noninteractive
+    (kill-buffer "*#fake*")))
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#46339: 28.0.50; ERC likely bug with `erc-previous-command'
  2021-02-08 11:07 ` J.P.
@ 2021-02-09 20:46   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-20  2:35   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-27  4:35   ` Lars Ingebrigtsen
  2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-02-09 20:46 UTC (permalink / raw)
  To: 46339; +Cc: emacs-erc

J.P. wrote:

>> what does that mean? `erc-next-command' works so a bug is
>> perhaps likely.
>
> I think it's expecting an erc-input struct object, as passed
> by the hook erc-pre-send-functions.
>
> Would something like the following work? [...]

How do you apply a patch once downloaded and opened in Emacs?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46339: 28.0.50; ERC likely bug with `erc-previous-command'
  2021-02-08 11:07 ` J.P.
  2021-02-09 20:46   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-02-20  2:35   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-27  4:35   ` Lars Ingebrigtsen
  2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-02-20  2:35 UTC (permalink / raw)
  To: 46339; +Cc: emacs-erc

J.P. wrote:

>> what does that mean? `erc-next-command' works so a bug is
>> perhaps likely.
>
> I think it's expecting an erc-input struct object, as passed
> by the hook erc-pre-send-functions.
>
> Would something like the following work?

Sorry for the delay. I didn't know how to apply the patch.
Got help from #erc [last]

And it works! Bug gone!

Great job General Purpose! (Jeep :)) J.P.

My #3 ERC bug - I'm rolling. Now when I know how to apply
patches, ikr? the sky is the limit :)

So, accept the patch already :P

[how to apply a patch]

Emacs source root:

  $ patch -p1 < PATCH

Then byte-compile:

  $ emacs --batch -f batch-byte-compile FILES

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46339: 28.0.50; ERC likely bug with `erc-previous-command'
  2021-02-08 11:07 ` J.P.
  2021-02-09 20:46   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-20  2:35   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-02-27  4:35   ` Lars Ingebrigtsen
  2 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-27  4:35 UTC (permalink / raw)
  To: J.P.; +Cc: 46339, emacs-erc

"J.P." <jp@neverwas.me> writes:

> I think it's expecting an erc-input struct object, as passed by the hook
> erc-pre-send-functions.
>
> Would something like the following work?

Looks good to me; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-27  4:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06  6:39 bug#46339: 28.0.50; ERC likely bug with `erc-previous-command' Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-08 11:07 ` J.P.
2021-02-09 20:46   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-20  2:35   ` Emanuel Berg via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-27  4:35   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).