all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Cc: emacs-devel@gnu.org
Subject: `calc-show-banner'
Date: 29 May 2002 15:06:30 +0900	[thread overview]
Message-ID: <buok7pnzdw9.fsf@mcspd15.ucom.lsi.nec.co.jp> (raw)

[-- Attachment #1: Type: text/plain, Size: 666 bytes --]

Hi Colin,

What do you think of the following patch?  I added a variable to control
whether calc displays `--- Emacs Calculator Mode ---' above the stack or
not (it seems useless to me, so I don't want to waste the space).

It seems to work OK, based on my um, light testing, but I'm not sure
whether there are additional places that need to be tweaked or not, or
whether I fit it into calc in the best way.

Also, the patch makes a binding to toggle the banner display (`d @' --
couldn't find many unbound keys!), but I'm not sure if it's worth it to
have a command at all, or whether it should just be a .emacs-only variable.

Thanks,

-Miles


Here's the patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch to make calc's banner-line optional --]
[-- Type: text/x-patch, Size: 3246 bytes --]

2002-05-29  Miles Bader  <miles@gnu.org>

	* calc/calc.el (calc-show-banner): New variable.
	(calc-refresh): Only show banner if `calc-show-banner' is non-nil.
	(calc-mode-var-list): Add `calc-show-banner'.
	* calc/calc-ext.el (calc-init-extensions): Add binding for `d@'.
	(calc-toggle-banner): New function.

Index: lisp/calc/calc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calc/calc.el,v
retrieving revision 1.12
diff -u -r1.12 calc.el
--- lisp/calc/calc.el	14 Apr 2002 05:50:05 -0000	1.12
+++ lisp/calc/calc.el	29 May 2002 05:58:16 -0000
@@ -249,6 +249,9 @@
 ;; Entries are 3-lists:  Formula, Height (in lines), Selection (or nil).
 (defvar calc-stack '((top-of-stack 1 nil)))
 
+(defvar calc-show-banner t
+  "*If non-nil, show a friendly greeting above the stack.")
+
 ;; Index into calc-stack of "top" of stack.
 ;; This is 1 unless calc-truncate-stack has been used.
 ;;(defvar calc-stack-top 1)
@@ -581,7 +584,8 @@
 			       (calc-gnuplot-geometry nil)
 			       (calc-graph-default-resolution 15)
 			       (calc-graph-default-resolution-3d 5)
-			       (calc-invocation-macro nil)))
+			       (calc-invocation-macro nil)
+			       (calc-show-banner t)))
 
 (defconst calc-local-var-list '(calc-stack
 				calc-stack-top
@@ -1702,10 +1706,12 @@
 	 (setq calc-any-selections nil
 	       calc-any-evaltos nil)
 	 (erase-buffer)
-	 (insert "--- Emacs Calculator Mode ---\n")
+	 (when calc-show-banner
+	   (insert "--- Emacs Calculator Mode ---\n"))
 	 (while thing
 	   (goto-char (point-min))
-	   (forward-line 1)
+	   (when calc-show-banner
+	     (forward-line 1))
 	   (insert (math-format-stack-value (car thing)) "\n")
 	   (setq thing (cdr thing)))
 	 (calc-renumber-stack)
Index: lisp/calc/calc-ext.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calc/calc-ext.el,v
retrieving revision 1.9
diff -u -r1.9 calc-ext.el
--- lisp/calc/calc-ext.el	26 Feb 2002 19:54:21 -0000	1.9
+++ lisp/calc/calc-ext.el	29 May 2002 05:58:13 -0000
@@ -1,6 +1,6 @@
 ;;; calc-ext.el --- various extension functions for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Colin Walters <walters@debian.org>
@@ -250,6 +250,7 @@
   (define-key calc-mode-map "d'" 'calc-display-raw)
   (define-key calc-mode-map "d " 'calc-refresh)
   (define-key calc-mode-map "d\r" 'calc-refresh-top)
+  (define-key calc-mode-map "d@" 'calc-toggle-banner)
 
   (define-key calc-mode-map "f" nil)
   (define-key calc-mode-map "f?" 'calc-f-prefix-help)
@@ -1489,6 +1490,11 @@
       (if calc-embedded-info (calc-embedded-modes-change var))
       (symbol-value (car var)))))
 
+(defun calc-toggle-banner ()
+  (interactive)
+  (setq calc-show-banner (not calc-show-banner))
+  (calc-refresh))
+
 (defun calc-refresh-top (n)
   (interactive "p")
   (calc-wrapper
@@ -1533,7 +1539,6 @@
 	   (setq num (1- num)))))
   (and calc-embedded-active which-var
        (calc-embedded-var-change which-var)))
-
 
 (defun calc-push (&rest vals)
   (calc-push-list vals))

[-- Attachment #3: Type: text/plain, Size: 88 bytes --]




-- 
A zen-buddhist walked into a pizza shop and
said, "Make me one with everything."

             reply	other threads:[~2002-05-29  6:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-29  6:06 Miles Bader [this message]
2002-05-29  7:32 ` `calc-show-banner' Colin Walters

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=buok7pnzdw9.fsf@mcspd15.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.