From: Juri Linkov <juri@linkov.net>
To: Daniel Colascione <dancol@dancol.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Multi-line input (was: Losing minibuffer input)
Date: Fri, 05 Dec 2014 02:38:03 +0200 [thread overview]
Message-ID: <87oarjklgc.fsf_-_@mail.linkov.net> (raw)
In-Reply-To: <546E1845.2010301@dancol.org> (Daniel Colascione's message of "Thu, 20 Nov 2014 08:35:17 -0800")
> S-RET is a good idea; I've seen this keybinding used in lots of other
> programs for "insert a newline without executing an action".
Other problematic place where S-RET could help to insert a newline
is shell input. What is worse in shell than in the minibuffer
typing RET accidentally in the middle of multi-line shell input
causes a mess: it sends the part before point, and leaves
the remaining lines dangling at the end of the shell buffer.
This patch gets the input until the end of the possibly multi-line
input field instead of only the end of the line:
diff --git a/lisp/comint.el b/lisp/comint.el
index da37827..da21d66 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -457,6 +457,7 @@ (defvar comint-mode-map
(define-key map [?\C-c ?\M-s] 'comint-next-matching-input-from-input)
(define-key map "\e\C-l" 'comint-show-output)
(define-key map "\C-m" 'comint-send-input)
+ (define-key map [S-return] 'newline)
(define-key map "\C-d" 'comint-delchar-or-maybe-eof)
;; The following two are standardly bound to delete-forward-char,
;; but they should never do EOF, just delete.
@@ -1781,7 +1782,7 @@ (defun comint-send-input (&optional no-newline artificial)
(widen)
(let* ((pmark (process-mark proc))
(intxt (if (>= (point) (marker-position pmark))
- (progn (if comint-eol-on-send (end-of-line))
+ (progn (if comint-eol-on-send (goto-char (field-end)))
(buffer-substring pmark (point)))
(let ((copy (funcall comint-get-old-input)))
(goto-char pmark)
While checking this, I also noticed a problem in searching the history of
multi-line entries. `comint-line-beginning-position' operates only
on the current line, so it too should be replaced with `field-beginning':
diff --git a/lisp/comint.el b/lisp/comint.el
index da37827..da21d66 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1475,7 +1476,7 @@ (defun comint-history-isearch-search ()
(or
;; 1. First try searching in the initial comint text
(funcall search-fun string
- (if isearch-forward bound (comint-line-beginning-position))
+ (if isearch-forward bound (field-beginning))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the comint successively, and search the string
@@ -1491,7 +1492,7 @@ (defun comint-history-isearch-search ()
(when (null comint-input-ring-index)
(error "End of history; no next item"))
(comint-next-input 1)
- (goto-char (comint-line-beginning-position)))
+ (goto-char (field-beginning)))
(t
;; Signal an error here explicitly, because
;; `comint-previous-input' doesn't signal an error.
@@ -1509,7 +1510,7 @@ (defun comint-history-isearch-search ()
(unless isearch-forward
;; For backward search, don't search
;; in the comint prompt
- (comint-line-beginning-position))
+ (field-beginning))
noerror)))
;; Return point of the new search result
(point))
next prev parent reply other threads:[~2014-12-05 0:38 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 17:57 Losing minibuffer input Juri Linkov
2014-11-09 18:17 ` Óscar Fuentes
2014-11-09 18:33 ` Juri Linkov
2014-11-09 18:53 ` Drew Adams
2014-11-13 20:23 ` Juri Linkov
2014-11-14 11:16 ` Dmitry Gutov
2014-11-18 21:36 ` Juri Linkov
2014-11-20 22:38 ` Johan Bockgård
2014-11-20 23:58 ` Juri Linkov
2014-11-21 7:37 ` previous-line, next-line at the first, last lines of the buffer Ivan Shmakov
2014-11-21 8:49 ` Eli Zaretskii
2014-11-21 9:12 ` Ivan Shmakov
2014-11-30 13:31 ` Stefan Monnier
2014-11-09 18:52 ` Losing minibuffer input Drew Adams
2014-11-09 18:52 ` Drew Adams
2014-11-13 21:14 ` Stefan Monnier
2014-11-18 21:40 ` Juri Linkov
2014-11-19 4:22 ` Drew Adams
2014-11-20 23:52 ` Juri Linkov
2014-11-21 0:24 ` Drew Adams
2014-11-20 16:35 ` Daniel Colascione
2014-11-20 23:55 ` Juri Linkov
2014-12-05 0:38 ` Juri Linkov [this message]
2014-12-05 2:03 ` Multi-line input Stefan Monnier
2014-12-05 16:24 ` Yuri Khan
2014-12-05 18:45 ` Stefan Monnier
2014-12-05 22:43 ` Richard Stallman
[not found] ` <<E1Xx1bN-0007f9-Ut@fencepost.gnu.org>
2014-12-05 23:02 ` Drew Adams
2014-12-06 12:06 ` Richard Stallman
[not found] ` <<94e0230f-c396-4266-8ada-9816d8118946@default>
[not found] ` <<E1XxE8T-0002OE-U9@fencepost.gnu.org>
2014-12-06 16:44 ` Drew Adams
2014-12-05 23:43 ` Juri Linkov
2014-12-06 3:20 ` Drew Adams
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=87oarjklgc.fsf_-_@mail.linkov.net \
--to=juri@linkov.net \
--cc=dancol@dancol.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.
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).