emacs-devel
[Top][All Lists]
Advanced

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

read-only comint-prompt


From: Luc Teirlinck
Subject: read-only comint-prompt
Date: Mon, 26 Apr 2004 19:11:40 -0500 (CDT)

I recently implemented changes to the ielm read-only prompt.  An
obvious question is: what is so special about the _ielm_ prompt vs
other comint prompts?  Making the comint prompt _optionally_ read-only
(not by default) has been discussed before, quite a while ago, but
apparently nothing has been done.  What about the following as a
start?  Like the new ielm prompt, it also protects against accidental
pasting inside the prompt (most notably in the invisible trailing
space part of the prompt).  If this seems OK, then maybe further
possible improvements might be functions comint-kill-whole-line and
comint-kill-region, whose only difference with the regular functions
would be that they bind inhibit-read-only to t around the call,  That
would help people like me who like to "clean up" comint buffers after
messing them up by doing stupidities.

===File ~/comint-diff=======================================
*** comint.el   22 Apr 2004 18:50:10 -0500      1.295
--- comint.el   26 Apr 2004 16:37:34 -0500      
***************
*** 171,176 ****
--- 171,184 ----
  
  This is a good thing to set in mode hooks.")
  
+ (defcustom comint-prompt-read-only nil
+   "If non-nil, the comint prompt is read only.
+ This does not affect existing prompts.
+ Certain derived modes may override this option."
+   :type 'boolean
+   :group 'comint
+   :version "21.4")
+ 
  (defvar comint-delimiter-argument-list ()
    "List of characters to recognise as separate arguments in input.
  Strings comprising a character in this list will separate the arguments
***************
*** 1687,1702 ****
                (let ((inhibit-read-only t))
                  (add-text-properties comint-last-output-start (point)
                                       '(rear-nonsticky t
!                                        field output
!                                        inhibit-line-move-field-capture t))))
  
            ;; Highlight the prompt, where we define `prompt' to mean
            ;; the most recent output that doesn't end with a newline.
!           (unless (and (bolp) (null comint-last-prompt-overlay))
!             ;; Need to create or move the prompt overlay (in the case
!             ;; where there is no prompt ((bolp) == t), we still do
!             ;; this if there's already an existing overlay).
!             (let ((prompt-start (save-excursion (forward-line 0) (point))))
                (if comint-last-prompt-overlay
                    ;; Just move an existing overlay
                    (move-overlay comint-last-prompt-overlay
--- 1695,1717 ----
                (let ((inhibit-read-only t))
                  (add-text-properties comint-last-output-start (point)
                                       '(rear-nonsticky t
!                                      field output
!                                      inhibit-line-move-field-capture t))))
  
            ;; Highlight the prompt, where we define `prompt' to mean
            ;; the most recent output that doesn't end with a newline.
!           (let ((prompt-start (save-excursion (forward-line 0) (point)))
!                 (inhibit-read-only t))
!             (when comint-prompt-read-only
!               (add-text-properties
!                prompt-start (point)
!                '(read-only t rear-non-sticky t front-sticky (read-only))))
!             (unless (and (bolp) (null comint-last-prompt-overlay))
!               ;; Need to create or move the prompt overlay (in the case
!               ;; where there is no prompt ((bolp) == t), we still do
!               ;; this if there's already an existing overlay).
!             
!               
                (if comint-last-prompt-overlay
                    ;; Just move an existing overlay
                    (move-overlay comint-last-prompt-overlay
============================================================

===File ~/ielm-diff=========================================
*** ielm.el     25 Apr 2004 21:59:05 -0500      1.41
--- ielm.el     26 Apr 2004 14:47:55 -0500      
***************
*** 478,490 ****
    (setq comint-input-sender 'ielm-input-sender)
    (setq comint-process-echoes nil)
    (make-local-variable 'comint-dynamic-complete-functions)
!   (set (make-local-variable 'ielm-prompt)
!        (if ielm-prompt-read-only
!          (propertize ielm-prompt
!                      'read-only t
!                      'rear-nonsticky t
!                      'front-sticky '(read-only))
!        ielm-prompt))
    (setq comint-dynamic-complete-functions
        '(ielm-tab comint-replace-by-expanded-history ielm-complete-filename 
ielm-complete-symbol))
    (setq comint-get-old-input 'ielm-get-old-input)
--- 478,485 ----
    (setq comint-input-sender 'ielm-input-sender)
    (setq comint-process-echoes nil)
    (make-local-variable 'comint-dynamic-complete-functions)
!   (set (make-local-variable 'ielm-prompt) ielm-prompt)
!   (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only)
    (setq comint-dynamic-complete-functions
        '(ielm-tab comint-replace-by-expanded-history ielm-complete-filename 
ielm-complete-symbol))
    (setq comint-get-old-input 'ielm-get-old-input)
============================================================




reply via email to

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