1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Add user option to inhibit Calc startup message (bug#79143)

* doc/misc/calc.texi (Customizing Calc): Document the new option.
* etc/NEWS: Document the new option.
* lisp/calc/calc.el (calc-inhibit-startup-message): New option to
inhibit Calc’s startup message.
(calc): Respect the option in Calc’s startup code.
* test/lisp/calc/calc-tests.el (ert): Require ert-x for
'ert-with-message-capture'.
(calc-inhibit-startup-message): Test the new user option.
This commit is contained in:
Sean Devlin 2025-08-02 09:47:14 -05:00 committed by Eli Zaretskii
parent 8c71ef0f8e
commit aa60f16e66
4 changed files with 42 additions and 7 deletions

View file

@ -35714,6 +35714,14 @@ The default value of @code{calc-string-maximum-character} is @code{0xFF}
or 255. or 255.
@end defvar @end defvar
@defvar calc-inhibit-startup-message
The variable @code{calc-inhibit-startup-message} controls display of a
welcome message when starting Calc. If it is @code{nil} (the default),
Calc will print a brief message listing key bindings to get help or to
quit. If it is non-@code{nil}, Calc will start without printing
anything.
@end defvar
@node Reporting Bugs @node Reporting Bugs
@appendix Reporting Bugs @appendix Reporting Bugs

View file

@ -2605,6 +2605,11 @@ Latin-1 range 0-255. This hard-coded maximum is replaced by
the display of matching vectors as Unicode strings. The default value the display of matching vectors as Unicode strings. The default value
is 0xFF or 255 to preserve the existing behavior. is 0xFF or 255 to preserve the existing behavior.
+++
*** New user option 'calc-inhibit-startup-message'.
If it is non-nil, inhibit Calc from printing its startup message. The
default value is nil to preserve the existing behavior.
** Time ** Time
*** New user option 'world-clock-sort-order'. *** New user option 'world-clock-sort-order'.

View file

@ -1473,6 +1473,11 @@ commands given here will actually operate on the *Calculator* stack."
(require 'calc-ext) (require 'calc-ext)
(calc-set-language calc-language calc-language-option t))) (calc-set-language calc-language calc-language-option t)))
(defcustom calc-inhibit-startup-message nil
"If non-nil, inhibit the Calc startup message."
:version "31.1"
:type 'boolean)
(defcustom calc-make-windows-dedicated nil (defcustom calc-make-windows-dedicated nil
"If non-nil, windows displaying Calc buffers will be marked dedicated. "If non-nil, windows displaying Calc buffers will be marked dedicated.
See `window-dedicated-p' for what that means." See `window-dedicated-p' for what that means."
@ -1524,9 +1529,10 @@ See `window-dedicated-p' for what that means."
(with-current-buffer (calc-trail-buffer) (with-current-buffer (calc-trail-buffer)
(and calc-display-trail (and calc-display-trail
(calc-trail-display 1 t))) (calc-trail-display 1 t)))
(message (substitute-command-keys (unless calc-inhibit-startup-message
(concat "Welcome to the GNU Emacs Calculator! \\<calc-mode-map>" (message (substitute-command-keys
"Press \\[calc-help] or \\[calc-help-prefix] for help, \\[calc-quit] to quit"))) (concat "Welcome to the GNU Emacs Calculator! \\<calc-mode-map>"
"Press \\[calc-help] or \\[calc-help-prefix] for help, \\[calc-quit] to quit"))))
(run-hooks 'calc-start-hook) (run-hooks 'calc-start-hook)
(and (windowp full-display) (and (windowp full-display)
(window-point full-display) (window-point full-display)
@ -1534,10 +1540,11 @@ See `window-dedicated-p' for what that means."
(and calc-make-windows-dedicated (and calc-make-windows-dedicated
(set-window-dedicated-p nil t)) (set-window-dedicated-p nil t))
(calc-check-defines) (calc-check-defines)
(when (and calc-said-hello interactive) (unless calc-inhibit-startup-message
(sit-for 2) (when (and calc-said-hello interactive)
(message "")) (sit-for 2)
(setq calc-said-hello t))))) (message ""))
(setq calc-said-hello t))))))
;;;###autoload ;;;###autoload
(defun full-calc (&optional interactive) (defun full-calc (&optional interactive)

View file

@ -26,6 +26,7 @@
(require 'cl-lib) (require 'cl-lib)
(require 'ert) (require 'ert)
(require 'ert-x)
(require 'calc) (require 'calc)
(require 'calc-ext) (require 'calc-ext)
(require 'calc-units) (require 'calc-units)
@ -946,5 +947,19 @@ an error in the comparison."
(should-error (math-vector-is-string cplx-vec) (should-error (math-vector-is-string cplx-vec)
:type 'wrong-type-argument)))) :type 'wrong-type-argument))))
(ert-deftest calc-inhibit-startup-message ()
"Test user option `calc-inhibit-startup-message'."
(let ((welcome-message "Welcome to the GNU Emacs Calculator!"))
(ert-with-message-capture messages
(let ((calc-inhibit-startup-message t))
(calc))
(should-not (string-match-p welcome-message messages))
(calc-quit))
(ert-with-message-capture messages
(let ((calc-inhibit-startup-message nil))
(calc))
(should (string-match-p welcome-message messages))
(calc-quit))))
(provide 'calc-tests) (provide 'calc-tests)
;;; calc-tests.el ends here ;;; calc-tests.el ends here