unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32470: rcirc-debug: ignore read-only; do not move point if mid-buffer; use %F
@ 2018-08-18  8:57 Ivan Shmakov
  2018-09-14 12:22 ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Shmakov @ 2018-08-18  8:57 UTC (permalink / raw)
  To: 32470

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

Package:  emacs
Severity: wishlist
Tags: patch

	I find it quite convenient to be able to make the *rcirc debug*
	buffer read-only, so that I won’t be able to change it by
	accident.  This of course requires the rcirc-debug function to
	use inhibit-read-only.

	Another usability tweak is to restore point after insertion –
	unless it was at the end of the (visible portion of the) buffer
	before.  (Hence allowing the buffer to scroll normally after
	end-of-buffer is used.)

	Also, while we’re at, %Y-%m-%d can be replaced with the
	equivalent %F in the format-time-string argument; and concat
	is useless as ‘insert’ effectively concatenates its string
	arguments already.

	I’m somewhat unsure if this change is NEWS-worthy; if so,
	I suggest the following entry.

** rcirc

+++
*** The 'rcirc-debug-buffer' can now be made read-only; it will be
ignored when adding debug text to it.  Also, the point will not be
moved, unless it's set to the end of the visible portion of the buffer.

	Please thus consider the patch MIMEd.

-- 
FSF associate member #7257  np. Funiculì, funiculà — Luciano Pavarotti

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/patch, Size: 1724 bytes --]

From: Ivan Shmakov <ivan@siamics.net>
Subject: Improve user convenience of the rcirc debug buffer
Date: Sat, 18 Aug 2018 08:57:08 +0000

* lisp/net/rcirc.el (rcirc-debug): Ignore rcirc-debug-buffer read-only
status.  Restore point after insertion unless it was at the end.
Replace %Y-%m-%d with the equivalent %F in format-time-string; remove
useless concat.  (Bug#-XXX-)
---

--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -670,16 +670,24 @@
   "If non-nil, write information to `rcirc-debug-buffer'.")
 (defun rcirc-debug (process text)
   "Add an entry to the debug log including PROCESS and TEXT.
-Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-flag'
-is non-nil."
+Debug text is appended to `rcirc-debug-buffer' if `rcirc-debug-flag'
+is non-nil.
+
+For convenience, the read-only state of the debug buffer is ignored.
+When the point is at the end of the visible portion of the buffer, it
+is moved to after the text inserted.  Otherwise the point is not moved."
   (when rcirc-debug-flag
     (with-current-buffer (get-buffer-create rcirc-debug-buffer)
-      (goto-char (point-max))
-      (insert (concat
-	       "["
-	       (format-time-string "%Y-%m-%dT%T ") (process-name process)
-	       "] "
-	       text)))))
+      (let ((old (set-marker (make-marker) (point))))
+        (set-marker-insertion-type old t)
+        (goto-char (point-max))
+        (let ((inhibit-read-only t))
+          (terpri (current-buffer) t)
+          (insert "["
+                  (format-time-string "%FT%T ") (process-name process)
+                  "] "
+                  text))
+        (goto-char old)))))
 
 (define-obsolete-variable-alias 'rcirc-sentinel-hooks
   'rcirc-sentinel-functions "24.3")


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

end of thread, other threads:[~2019-05-16 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18  8:57 bug#32470: rcirc-debug: ignore read-only; do not move point if mid-buffer; use %F Ivan Shmakov
2018-09-14 12:22 ` Noam Postavsky
2018-09-14 19:05   ` Ivan Shmakov
2018-09-18 22:46     ` Noam Postavsky
2019-05-16 11:26       ` Noam Postavsky

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