changeset 109682:bc0b9af387a7

calc.el (calc-trail-mode,calc-refresh): Use `face' property to italicize headers. (calc-highlight-selections-with-faces): New variable. (calc-selected-face, calc-nonselected-face): New faces. calccomp.el (math-comp-highlight-string): Use `calc-highlight-selections-with-faces' to determine how to highlight subformulas. calc-sel.el (calc-show-selections): Change message to something appropriate. calc.texi (Making Selections, Selecting Subformulas) (Customizing Calc): Mention how to use faces to emphasize selected subformulas.
author Jay Belanger <jay.p.belanger@gmail.com>
date Sat, 07 Aug 2010 22:04:57 -0500
parents 232ba164887b
children 232cf2881573 5cfe70ae40e5
files doc/misc/ChangeLog doc/misc/calc.texi lisp/ChangeLog lisp/calc/calc-sel.el lisp/calc/calc.el lisp/calc/calccomp.el
diffstat 6 files changed, 92 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Sat Aug 07 19:57:07 2010 -0400
+++ b/doc/misc/ChangeLog	Sat Aug 07 22:04:57 2010 -0500
@@ -1,3 +1,9 @@
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc.texi (Making Selections, Selecting Subformulas)
+	(Customizing Calc): Mention how to use faces to emphasize selected
+	sub-formulas.
+
 2010-08-05  Michael Albinus  <michael.albinus@gmx.de>
 
 	* tramp.texi (External packages): File attributes cache flushing
--- a/doc/misc/calc.texi	Sat Aug 07 19:57:07 2010 -0400
+++ b/doc/misc/calc.texi	Sat Aug 07 22:04:57 2010 -0500
@@ -21513,7 +21513,11 @@
 
 @noindent
 Every character not part of the sub-formula @samp{b} has been changed
-to a dot.  The @samp{*} next to the line number is to remind you that
+to a dot. (If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the characters
+not part of the sub-formula are de-emphasized by using a less
+noticeable face instead of using dots. @pxref{Displaying Selections}.)
+The @samp{*} next to the line number is to remind you that
 the formula has a portion of it selected.  (In this case, it's very
 obvious, but it might not always be.  If Embedded mode is enabled,
 the word @samp{Sel} also appears in the mode line because the stack
@@ -21726,6 +21730,9 @@
 @noindent
 @kindex j d
 @pindex calc-show-selections
+@vindex calc-highlight-selections-with-faces
+@vindex calc-selected-face
+@vindex calc-nonselected-face
 The @kbd{j d} (@code{calc-show-selections}) command controls how
 selected sub-formulas are displayed.  One of the alternatives is
 illustrated in the above examples; if we press @kbd{j d} we switch
@@ -21740,6 +21747,13 @@
         . . . .                   2 x + 1
 @end group
 @end smallexample
+If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the
+non-selected portion of the formula will be de-emphasized by using a
+less noticeable face (@code{calc-nonselected-face}) instead of dots
+and the selected sub-formula will be highlighted by using a more
+noticeable face (@code{calc-selected-face}) instead of @samp{#}
+signs. (@pxref{Customizing Calc}.)
 
 @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
 @subsection Operating on Selections
@@ -34911,7 +34925,7 @@
 
 Calc is controlled by many variables, most of which can be reset
 from within Calc.  Some variables are less involved with actual
-calculation, and can be set outside of Calc using Emacs's
+calculation and can be set outside of Calc using Emacs's
 customization facilities.  These variables are listed below.
 Typing @kbd{M-x customize-variable RET @var{variable-name} RET}
 will bring up a buffer in which the variable's value can be redefined.
@@ -35197,6 +35211,22 @@
 and @code{calc-embedded-open-close-plain-alist}.
 @end defvar
 
+@defvar calc-highlight-selections-with-faces
+@defvarx calc-selected-face
+@defvarx calc-nonselected-face
+The variable @code{calc-highlight-selections-with-faces} 
+determines how selected sub-formulas are distinguished.
+If @code{calc-highlight-selections-with-faces} is nil, then 
+a selected sub-formula is distinguished either by changing every
+character not part of the sub-formula with a dot or by changing every
+character in the sub-formula with a @samp{#} sign.  
+If @code{calc-highlight-selections-with-faces} is t,
+then a selected sub-formula is distinguished either by displaying the
+non-selected portion of the formula with @code{calc-nonselected-face} 
+or by displaying the selected sub-formula with
+@code{calc-nonselected-face}. (@pxref{Displaying Selections}.)
+@end defvar
+
 @defvar calc-multiplication-has-precedence
 The variable @code{calc-multiplication-has-precedence} determines
 whether multiplication has precedence over division in algebraic
--- a/lisp/ChangeLog	Sat Aug 07 19:57:07 2010 -0400
+++ b/lisp/ChangeLog	Sat Aug 07 22:04:57 2010 -0500
@@ -1,3 +1,17 @@
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc/calc.el (calc-trail-mode,calc-refresh): Use `face' property
+	to italicize headers.
+	(calc-highlight-selections-with-faces): New variable.
+	(calc-selected-face, calc-nonselected-face): New faces.
+
+	* calc/calccomp.el (math-comp-highlight-string): Use
+	`calc-highlight-selections-with-faces' to determine how to highlight
+	sub-formulas.
+
+	* calc/calc-sel.el (calc-show-selections): Change message to when
+	using faces to highlight selections.
+
 2010-08-07  Michael R. Mauger  <mmaug@yahoo.com>
 
 	* progmodes/sql.el (sql-mode-sqlite-font-lock-keywords): Added
--- a/lisp/calc/calc-sel.el	Sat Aug 07 19:57:07 2010 -0400
+++ b/lisp/calc/calc-sel.el	Sat Aug 07 22:04:57 2010 -0500
@@ -309,6 +309,8 @@
        (setq n (1+ n))))
    (calc-clear-command-flag 'position-point)))
 
+(defvar calc-highlight-selections-with-faces)
+
 (defun calc-show-selections (arg)
   (interactive "P")
   (calc-wrapper
@@ -330,8 +332,12 @@
 		(setcar (nthcdr 2 calc-selection-cache-entry) nil)
 		(calc-change-current-selection sel)))))
    (message (if calc-show-selections
-		"Displaying only selected part of formulas"
-	      "Displaying all but selected part of formulas"))))
+                (if calc-highlight-selections-with-faces
+                    "De-emphasizing all but selected part of formulas"
+                  "Displaying only selected part of formulas")
+              (if calc-highlight-selections-with-faces
+                  "Emphasizing selected part of formulas"
+                "Displaying all but selected part of formulas")))))
 
 ;; The variables calc-final-point-line and calc-final-point-column
 ;; are declared in calc.el, and are used throughout.
--- a/lisp/calc/calc.el	Sat Aug 07 19:57:07 2010 -0400
+++ b/lisp/calc/calc.el	Sat Aug 07 22:04:57 2010 -0500
@@ -425,6 +425,27 @@
   :group 'calc
   :type 'integer)
 
+(defcustom calc-highlight-selections-with-faces
+  nil
+  "If non-nil, use a separate face to indicate selected sub-formulas.
+If `calc-show-selections' is non-nil, then selected sub-formulas are shown
+by displaying the rest of the formula in `calc-nonselected-face'.  
+If `calc-show-selections' is nil, then selected sub-formulas are shown
+by displaying the sub-formula in `calc-selected-face'."
+  :group 'calc
+  :type 'boolean)
+
+(defface calc-nonselected-face
+  '((t :inherit shadow       
+       :slant italic))
+  "Face used to show the non-selected portion of a formula."
+  :group 'calc)
+
+(defface calc-selected-face
+  '((t :weight bold))
+  "Face used to show the selected portion of a formula."
+  :group 'calc)
+
 (defvar calc-bug-address "jay.p.belanger@gmail.com"
   "Address of the maintainer of Calc, for use by `report-calc-bug'.")
 
@@ -1385,8 +1406,7 @@
     (set (make-local-variable 'calc-main-buffer) buf))
   (when (= (buffer-size) 0)
     (let ((buffer-read-only nil))
-      (insert (propertize (concat "Emacs Calculator Trail\n")
-			  'font-lock-face 'italic))))
+      (insert (propertize "Emacs Calculator Trail\n" 'face 'italic))))
   (run-mode-hooks 'calc-trail-mode-hook))
 
 (defun calc-create-buffer ()
@@ -1976,7 +1996,7 @@
 	 (erase-buffer)
 	 (when calc-show-banner
 	   (insert (propertize "--- Emacs Calculator Mode ---\n"
-			       'font-lock-face 'italic)))
+			       'face 'italic)))
 	 (while thing
 	   (goto-char (point-min))
 	   (when calc-show-banner
--- a/lisp/calc/calccomp.el	Sat Aug 07 19:57:07 2010 -0400
+++ b/lisp/calc/calccomp.el	Sat Aug 07 22:04:57 2010 -0500
@@ -1339,12 +1339,15 @@
 
 (defun math-comp-highlight-string (s)
   (setq s (copy-sequence s))
-  (let ((i (length s)))
-    (while (>= (setq i (1- i)) 0)
-      (or (memq (aref s i) '(32 ?\n))
-	  (aset s i (if calc-show-selections ?\. ?\#)))))
-  s)
-
+  (if calc-highlight-selections-with-faces
+      (if (not calc-show-selections)
+          (propertize s 'face 'calc-selected-face)
+        (propertize s 'face 'calc-nonselected-face))
+    (let ((i (length s)))
+      (while (>= (setq i (1- i)) 0)
+        (or (memq (aref s i) '(32 ?\n))
+            (aset s i (if calc-show-selections ?\. ?\#)))))
+    s))
 
 ;; The variable math-comp-sel-tag is local to calc-find-selected-part
 ;; in calc-sel.el, but is used by math-comp-sel-flat-term and