Mercurial > emacs
comparison lisp/ielm.el @ 55224:649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
(ielm-prompt-internal): New variable.
(ielm-font-lock-keywords): Remove irrelevant ielm-prompt keyword.
(ielm-send-input): Delete unused variable `buf'.
(ielm-eval-input): Use `ielm-prompt-internal'.
(inferior-emacs-lisp-mode): Use new variables
`comint-prompt-read-only' and `ielm-prompt-internal'.
Get rid of obsolete variable `directory-sep-char'.
(ielm): Use `zerop'.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Thu, 29 Apr 2004 03:45:05 +0000 |
parents | 1a8fe9f88f09 |
children | 24a3d142d101 |
comparison
equal
deleted
inserted
replaced
55223:14d50685dce0 | 55224:649d109f3222 |
---|---|
50 :group 'ielm) | 50 :group 'ielm) |
51 | 51 |
52 (defcustom ielm-prompt-read-only t | 52 (defcustom ielm-prompt-read-only t |
53 "If non-nil, the IELM prompt is read only. | 53 "If non-nil, the IELM prompt is read only. |
54 Setting this variable does not affect existing IELM runs. | 54 Setting this variable does not affect existing IELM runs. |
55 | 55 This works by setting the buffer-local value of `comint-prompt-read-only'. |
56 You can give the IELM prompt more highly customized read-only | 56 Setting that value directly affects new prompts in the current buffer." |
57 type properties, by setting this option to nil, and then setting | |
58 `ielm-prompt', outside of Custom, to a string with the desired | |
59 text properties. | |
60 | |
61 Interrupting the IELM process with \\<ielm-map>\\[comint-interrupt-subjob], | |
62 and then restarting it using \\[ielm], makes the then current | |
63 default value affect _new_ prompts. However, executing \\[ielm] | |
64 does not have this effect on *ielm* buffers with a running process. | |
65 For IELM buffers that are not called `*ielm*', you can execute | |
66 \\[inferior-emacs-lisp-mode] in that IELM buffer to update the value, | |
67 for new prompts. This works even if the buffer has a running process." | |
68 :type 'boolean | 57 :type 'boolean |
69 :group 'ielm | 58 :group 'ielm |
70 :version "21.4") | 59 :version "21.4") |
71 | 60 |
72 (defcustom ielm-prompt "ELISP> " | 61 (defcustom ielm-prompt "ELISP> " |
73 "Prompt used in IELM. | 62 "Prompt used in IELM. |
74 Setting the default value does not affect existing IELM runs. | 63 Setting this variable does not affect existing IELM runs. |
75 `inferior-emacs-lisp-mode' converts this into a buffer-local | |
76 variable in IELM buffers. The buffer-local value is meant for | |
77 internal use by IELM. Do not try to set the buffer-local value | |
78 yourself in any way, unless you really know what you are doing. | |
79 | 64 |
80 Interrupting the IELM process with \\<ielm-map>\\[comint-interrupt-subjob], | 65 Interrupting the IELM process with \\<ielm-map>\\[comint-interrupt-subjob], |
81 and then restarting it using \\[ielm], makes the then current | 66 and then restarting it using \\[ielm], makes the then current |
82 _default_ value affect _new_ prompts. Unless the new prompt | 67 default value affect _new_ prompts. Unless the new prompt |
83 differs only in text properties from the old one, IELM will no | 68 differs only in text properties from the old one, IELM will no |
84 longer recognize the old prompts. However, executing \\[ielm] | 69 longer recognize the old prompts. However, executing \\[ielm] |
85 does not update the prompt of an *ielm* buffer with a running process. | 70 does not update the prompt of an *ielm* buffer with a running process. |
86 For IELM buffers that are not called `*ielm*', you can execute | 71 For IELM buffers that are not called `*ielm*', you can execute |
87 \\[inferior-emacs-lisp-mode] in that IELM buffer to update the value, | 72 \\[inferior-emacs-lisp-mode] in that IELM buffer to update the value, |
88 for new prompts. This works even if the buffer has a running process." | 73 for new prompts. This works even if the buffer has a running process." |
89 :type 'string | 74 :type 'string |
90 :group 'ielm) | 75 :group 'ielm) |
76 | |
77 (defvar ielm-prompt-internal "ELISP> " | |
78 "Stored value of `ielm-prompt' in the current IELM buffer. | |
79 This is an internal variable used by IELM. Its purpose is to | |
80 prevent a running IELM process from being messed up when the user | |
81 customizes `ielm-prompt'.") | |
91 | 82 |
92 (defcustom ielm-dynamic-return t | 83 (defcustom ielm-dynamic-return t |
93 "*Controls whether \\<ielm-map>\\[ielm-return] has intelligent behaviour in IELM. | 84 "*Controls whether \\<ielm-map>\\[ielm-return] has intelligent behaviour in IELM. |
94 If non-nil, \\[ielm-return] evaluates input for complete sexps, or inserts a newline | 85 If non-nil, \\[ielm-return] evaluates input for complete sexps, or inserts a newline |
95 and indents for incomplete sexps. If nil, always inserts newlines." | 86 and indents for incomplete sexps. If nil, always inserts newlines." |
176 (define-key ielm-map "\C-c\C-b" 'ielm-change-working-buffer) | 167 (define-key ielm-map "\C-c\C-b" 'ielm-change-working-buffer) |
177 (define-key ielm-map "\C-c\C-f" 'ielm-display-working-buffer) | 168 (define-key ielm-map "\C-c\C-f" 'ielm-display-working-buffer) |
178 (define-key ielm-map "\C-c\C-v" 'ielm-print-working-buffer)) | 169 (define-key ielm-map "\C-c\C-v" 'ielm-print-working-buffer)) |
179 | 170 |
180 (defvar ielm-font-lock-keywords | 171 (defvar ielm-font-lock-keywords |
181 (list | 172 '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" |
182 (cons (concat "^" (regexp-quote ielm-prompt)) 'font-lock-keyword-face) | |
183 '("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" | |
184 (1 font-lock-comment-face) | 173 (1 font-lock-comment-face) |
185 (2 font-lock-constant-face))) | 174 (2 font-lock-constant-face))) |
186 "Additional expressions to highlight in ielm buffers.") | 175 "Additional expressions to highlight in ielm buffers.") |
187 | 176 |
188 ;;; Completion stuff | 177 ;;; Completion stuff |
281 (setq ielm-input input)) | 270 (setq ielm-input input)) |
282 | 271 |
283 (defun ielm-send-input nil | 272 (defun ielm-send-input nil |
284 "Evaluate the Emacs Lisp expression after the prompt." | 273 "Evaluate the Emacs Lisp expression after the prompt." |
285 (interactive) | 274 (interactive) |
286 (let ((buf (current-buffer)) | 275 (let (ielm-input) ; set by ielm-input-sender |
287 ielm-input) ; set by ielm-input-sender | |
288 (comint-send-input) ; update history, markers etc. | 276 (comint-send-input) ; update history, markers etc. |
289 (ielm-eval-input ielm-input))) | 277 (ielm-eval-input ielm-input))) |
290 | 278 |
291 ;;; Utility functions | 279 ;;; Utility functions |
292 | 280 |
405 ;; There was no error, so shift the *** values | 393 ;; There was no error, so shift the *** values |
406 (setq *** **) | 394 (setq *** **) |
407 (setq ** *) | 395 (setq ** *) |
408 (setq * ielm-result)) | 396 (setq * ielm-result)) |
409 (setq ielm-output (concat ielm-output "\n")))) | 397 (setq ielm-output (concat ielm-output "\n")))) |
410 (setq ielm-output (concat ielm-output ielm-prompt)) | 398 (setq ielm-output (concat ielm-output ielm-prompt-internal)) |
411 (comint-output-filter (ielm-process) ielm-output))) | 399 (comint-output-filter (ielm-process) ielm-output))) |
412 | 400 |
413 ;;; Process and marker utilities | 401 ;;; Process and marker utilities |
414 | 402 |
415 (defun ielm-process nil | 403 (defun ielm-process nil |
476 (make-local-variable 'paragraph-start) | 464 (make-local-variable 'paragraph-start) |
477 (setq paragraph-start comint-prompt-regexp) | 465 (setq paragraph-start comint-prompt-regexp) |
478 (setq comint-input-sender 'ielm-input-sender) | 466 (setq comint-input-sender 'ielm-input-sender) |
479 (setq comint-process-echoes nil) | 467 (setq comint-process-echoes nil) |
480 (make-local-variable 'comint-dynamic-complete-functions) | 468 (make-local-variable 'comint-dynamic-complete-functions) |
481 (set (make-local-variable 'ielm-prompt) | 469 (set (make-local-variable 'ielm-prompt-internal) ielm-prompt) |
482 (if ielm-prompt-read-only | 470 (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only) |
483 (propertize ielm-prompt | |
484 'read-only t | |
485 'rear-nonsticky t | |
486 'front-sticky '(read-only)) | |
487 ielm-prompt)) | |
488 (setq comint-dynamic-complete-functions | 471 (setq comint-dynamic-complete-functions |
489 '(ielm-tab comint-replace-by-expanded-history ielm-complete-filename ielm-complete-symbol)) | 472 '(ielm-tab comint-replace-by-expanded-history ielm-complete-filename ielm-complete-symbol)) |
490 (setq comint-get-old-input 'ielm-get-old-input) | 473 (setq comint-get-old-input 'ielm-get-old-input) |
491 (make-local-variable 'comint-completion-addsuffix) | 474 (make-local-variable 'comint-completion-addsuffix) |
492 (setq comint-completion-addsuffix | 475 (setq comint-completion-addsuffix '("/" . "")) |
493 (cons (char-to-string directory-sep-char) "")) | |
494 | |
495 (setq major-mode 'inferior-emacs-lisp-mode) | 476 (setq major-mode 'inferior-emacs-lisp-mode) |
496 (setq mode-name "IELM") | 477 (setq mode-name "IELM") |
497 (setq mode-line-process '(":%s on " (:eval (buffer-name ielm-working-buffer)))) | 478 (setq mode-line-process '(":%s on " (:eval (buffer-name ielm-working-buffer)))) |
498 (use-local-map ielm-map) | 479 (use-local-map ielm-map) |
499 (set-syntax-table emacs-lisp-mode-syntax-table) | 480 (set-syntax-table emacs-lisp-mode-syntax-table) |
539 (unless comint-use-prompt-regexp-instead-of-fields | 520 (unless comint-use-prompt-regexp-instead-of-fields |
540 (let ((inhibit-read-only t)) | 521 (let ((inhibit-read-only t)) |
541 (add-text-properties | 522 (add-text-properties |
542 (point-min) (point-max) | 523 (point-min) (point-max) |
543 '(rear-nonsticky t field output inhibit-line-move-field-capture t)))) | 524 '(rear-nonsticky t field output inhibit-line-move-field-capture t)))) |
544 (comint-output-filter (ielm-process) ielm-prompt) | 525 (comint-output-filter (ielm-process) ielm-prompt-internal) |
545 (set-marker comint-last-input-start (ielm-pm)) | 526 (set-marker comint-last-input-start (ielm-pm)) |
546 (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)) | 527 (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)) |
547 | 528 |
548 (run-hooks 'ielm-mode-hook)) | 529 (run-hooks 'ielm-mode-hook)) |
549 | 530 |
566 Switches to the buffer `*ielm*', or creates it if it does not exist." | 547 Switches to the buffer `*ielm*', or creates it if it does not exist." |
567 (interactive) | 548 (interactive) |
568 (let (old-point) | 549 (let (old-point) |
569 (unless (comint-check-proc "*ielm*") | 550 (unless (comint-check-proc "*ielm*") |
570 (with-current-buffer (get-buffer-create "*ielm*") | 551 (with-current-buffer (get-buffer-create "*ielm*") |
571 (unless (eq (buffer-size) 0) (setq old-point (point))) | 552 (unless (zerop (buffer-size)) (setq old-point (point))) |
572 (inferior-emacs-lisp-mode))) | 553 (inferior-emacs-lisp-mode))) |
573 (pop-to-buffer "*ielm*") | 554 (pop-to-buffer "*ielm*") |
574 (when old-point (push-mark old-point)))) | 555 (when old-point (push-mark old-point)))) |
575 | 556 |
576 (provide 'ielm) | 557 (provide 'ielm) |