emacs-devel
[Top][All Lists]
Advanced

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

IELM prompt


From: Luc Teirlinck
Subject: IELM prompt
Date: Thu, 22 Apr 2004 21:09:28 -0500 (CDT)

There are (at least) three problems with the ielm prompt:

1.  It is non-customizable.  _Even_ if one sets ielm-prompt outside of
    Custom, the :set-function gets called anyway when ielm.el is loaded
    and the prompt becomes read-only, overriding the user's attempt at
    customizing the read-only-ness away.  (This is because of
    custom-initialize-reset.)

2.  It is not _really_ read-only.  One can paste stuff inside the
    prompt.  The default prompt is "ELISP> ".  The last space is
    invisibly part of the read-only prompt.  I just keep pasting stuff
    accidentally into that last space.  The pasted forms to be
    executed are then invisibly part of the read-only prompt with
    extremely confusing results.  This is very annoying.

3.  Flushing the output with C-c C-o produces an error instead of the
    intended "*** output flushed ***" message.  This is bad, because
    one likes to have a record of the fact that (probably extensive)
    output was flushed.

Below are a patch to ielm.el, eliminating problems (1) and (2) and a
(trivial) patch to comint.el eliminating (3).

The patch to comint.el binds inhibit-read-only to t in
comint-delete-output.  To me, that makes sense regardless of the
problems with the ielm prompt.  If one wants the previous output gone,
one wants it gone regardless of whether part of that output has the
read-only property.

The patch to ielm.el, apart from solving (1) and (2), also gets rid of
the unnecessary :get and :set keywords in the ielm-prompt defcustom,
letting inferior-emacs-lisp-mode do the work instead.  Customizing
the prompt would, by default, no longer affect existing *ielm*
buffers.  I believe that is an improvement, because two distinct
prompts in the same ielm run looks messy.  (I often save *ielm* buffers.)

If there are no objections, I could install these patches:

===File ~/comint-diff=======================================
*** comint.el   14 Apr 2004 14:14:13 -0500      1.294
--- comint.el   22 Apr 2004 18:50:10 -0500      
***************
*** 2006,2012 ****
  Does not delete the prompt."
    (interactive)
    (let ((proc (get-buffer-process (current-buffer)))
!       (replacement nil))
      (save-excursion
        (let ((pmark (progn (goto-char (process-mark proc))
                          (forward-line 0)
--- 2006,2013 ----
  Does not delete the prompt."
    (interactive)
    (let ((proc (get-buffer-process (current-buffer)))
!       (replacement nil)
!       (inhibit-read-only t))
      (save-excursion
        (let ((pmark (progn (goto-char (process-mark proc))
                          (forward-line 0)
============================================================

===File ~/ielm-diff=========================================
*** ielm.el     22 Apr 2004 08:56:46 -0500      1.36
--- ielm.el     22 Apr 2004 20:47:27 -0500      
***************
*** 49,60 ****
    :type 'boolean
    :group 'ielm)
  
  (defcustom ielm-prompt "ELISP> "
!   "Prompt used in IELM."
    :type 'string
!   :group 'ielm
!   :get #'(lambda (symbol) (substring-no-properties (symbol-value symbol)))
!   :set #'(lambda (symbol value) (set symbol (propertize value 'read-only t 
'rear-nonsticky t))))
  
  (defcustom ielm-dynamic-return t
    "*Controls whether \\<ielm-map>\\[ielm-return] has intelligent behaviour in 
IELM.
--- 49,80 ----
    :type 'boolean
    :group 'ielm)
  
+ (defcustom ielm-prompt-read-only t
+   "If non-nil, the IELM prompt is read only.
+ \\<ielm-map>\
+ Setting this variable does not affect existing IELM runs, unless
+ you execute the command \\[inferior-emacs-lisp-mode] \(_not_ just
+ \\[ielm]) in that IELM buffer.  Even then, it does not affect
+ existing prompts.
+ 
+ You can give the IELM prompt more highly customized read-only
+ type properties \(for instance make only part of the prompt
+ read-only), by setting this option to nil, and then setting
+ `ielm-prompt', outside of Custom, to a string with the desired
+ text properties."
+   :type 'boolean
+   :group 'ielm
+   :version "21.4")
+ 
  (defcustom ielm-prompt "ELISP> "
!   "Prompt used in IELM.
! \\<ielm-map>\
! Setting this variable does not affect existing IELM runs, unless
! you execute the command \\[inferior-emacs-lisp-mode] \(_not_ just
! \\[ielm]) in that IELM buffer.  Even then, it does not affect
! existing prompts."
    :type 'string
!   :group 'ielm)
  
  (defcustom ielm-dynamic-return t
    "*Controls whether \\<ielm-map>\\[ielm-return] has intelligent behaviour in 
IELM.
***************
*** 429,434 ****
--- 449,456 ----
  The behaviour of IELM may be customised with the following variables:
  * To stop beeping on error, set `ielm-noisy' to nil
  * If you don't like the prompt, you can change it by setting `ielm-prompt'.
+ * If you do not like that the prompt is (by default) read-only, set
+   `ielm-prompt-read-only' to nil.
  * Set `ielm-dynamic-return' to nil for bindings like `lisp-interaction-mode'
  * Entry to this mode runs `comint-mode-hook' and `ielm-mode-hook'
   (in that order).
***************
*** 443,448 ****
--- 465,477 ----
    (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)
============================================================




reply via email to

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