unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles.bader@necel.com>
Cc: nickrob@snap.net.nz, rogers-emacs@rgrjr.dyndns.org, emacs-devel@gnu.org
Subject: Re: comint-insert-input on non-command lines:  A trivial fix, a quibble, and a bug
Date: Mon, 08 May 2006 13:49:19 +0900	[thread overview]
Message-ID: <buobqu915ps.fsf@dhapc248.dev.necel.com> (raw)
In-Reply-To: <200605080349.k483neE2027538@jane.dms.auburn.edu> (Luc Teirlinck's message of "Sun, 7 May 2006 22:49:40 -0500 (CDT)")

Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> On closer inspection, what seems to cause this bug is that
> comint-insert-input contains:
>
>     (if (not (eq (get-char-property (point) 'field) 'input))
>     ;; No input at POS, fall back to the global definition.
>
> If comint-use-prompt-regexp is non-nil, then there are no field
> properties, so, despite what the comment claims, that condition does
> _not_ assure that there is no input at POS.

BTW, that function's use of fields is not well written.

Also, it uses `posn-set-point' _after_ getting the value of (point),
which doesn't make any sense to me.

The following seems to fix both problems (note new helper function following):


   (defun comint-insert-input (&optional event)
     "In a Comint buffer, set the current input to the previous input at point."
     ;; This doesn't use "e" because it is supposed to work
     ;; for events without parameters.
     (interactive (list last-input-event))
     (when event
       (posn-set-point (event-end event)))
     (let ((pos (point)))
       (if (not (eq (field-at-pos pos) 'input))
           ;; No input at POS, fall back to the global definition.
           (let* ((keys (this-command-keys))
                  (last-key (and (vectorp keys) (aref keys (1- (length keys)))))
                  (fun (and last-key (lookup-key global-map (vector last-key)))))
             (goto-char pos)
             (and fun (call-interactively fun)))
         (setq pos (point))
         ;; There's previous input at POS, insert it at the end of the buffer.
         (goto-char (point-max))
         ;; First delete any old unsent input at the end
         (delete-region
          (or (marker-position comint-accum-marker)
              (process-mark (get-buffer-process (current-buffer))))
          (point))
         ;; Insert the input at point
         (insert (field-string-no-properties pos)))))

   (defun field-at-pos (pos)
     "Return the field at position POS, taking stickiness etc into account"
     (let ((raw-field (get-char-property (field-beginning pos) 'field)))
       (if (eq raw-field 'boundary)
           (get-char-property (1- (field-end pos)) 'field)
         raw-field)))


I'll commit this unless somebody objects.


-Miles
-- 
"Though they may have different meanings, the cries of 'Yeeeee-haw!' and
 'Allahu akbar!' are, in spirit, not actually all that different."

  reply	other threads:[~2006-05-08  4:49 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-06 20:05 comint-insert-input on non-command lines: A trivial fix, a quibble, and a bug Bob Rogers
2006-05-08  0:31 ` Nick Roberts
2006-05-08  3:16   ` Luc Teirlinck
2006-05-08  3:49   ` Luc Teirlinck
2006-05-08  4:49     ` Miles Bader [this message]
2006-05-08 14:08       ` Stefan Monnier
2006-05-09  2:33         ` Miles Bader
2006-05-08  4:08   ` Luc Teirlinck
2006-05-08  4:18     ` Nick Roberts
2006-05-09  1:55       ` Bob Rogers
2006-05-09  3:11         ` Nick Roberts
2006-05-10  3:01           ` Bob Rogers
2006-05-10  5:57             ` Nick Roberts
2006-05-09  3:01       ` Luc Teirlinck
2006-05-09  3:21         ` Nick Roberts
2006-05-09  3:59           ` Luc Teirlinck
2006-05-09  6:17             ` Nick Roberts
2006-05-09 14:58               ` Luc Teirlinck
2006-05-10  1:09                 ` Nick Roberts
2006-05-10  1:13                   ` Luc Teirlinck
2006-05-10  1:58                   ` Miles Bader
2006-05-10  2:21                     ` Nick Roberts
2006-05-10  2:32                       ` Miles Bader
2006-05-10  3:50                         ` Nick Roberts
2006-05-10  4:09                           ` Miles Bader
2006-05-10  4:41                   ` Luc Teirlinck
2006-05-10  5:29                     ` Nick Roberts
2006-05-10  6:06                       ` Luc Teirlinck
2006-05-10  6:27                         ` Miles Bader
2006-05-10 21:38                         ` comint-insert-input on non-command lines: Nick Roberts
2006-05-11  1:12                           ` Luc Teirlinck
2006-05-11  1:33                           ` Luc Teirlinck
2006-05-11 18:31                             ` Richard Stallman
2006-05-11 20:29                               ` Nick Roberts
2006-05-11 22:40                               ` Luc Teirlinck
2006-05-14 23:29                                 ` Richard Stallman
2006-05-15  3:46                                   ` Luc Teirlinck
2006-05-15 20:37                                     ` Richard Stallman
2006-05-28  2:11                                       ` Luc Teirlinck
2006-05-28  3:48                                         ` Luc Teirlinck
2006-05-29  3:41                                         ` Nick Roberts
2006-05-29  3:58                                           ` Luc Teirlinck
2006-05-31  3:14                                             ` Luc Teirlinck
2006-05-31  3:24                                               ` Bob Rogers
2006-05-09  4:15           ` comint-insert-input on non-command lines: A trivial fix, a quibble, and a bug Luc Teirlinck
2006-05-10  5:19   ` Luc Teirlinck
2006-05-10  6:04     ` Nick Roberts

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=buobqu915ps.fsf@dhapc248.dev.necel.com \
    --to=miles.bader@necel.com \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    --cc=nickrob@snap.net.nz \
    --cc=rogers-emacs@rgrjr.dyndns.org \
    /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).