emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/calc/calc-sel.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/calc/calc-sel.el [lexbind]
Date: Wed, 08 Dec 2004 19:35:23 -0500

Index: emacs/lisp/calc/calc-sel.el
diff -c emacs/lisp/calc/calc-sel.el:1.4.4.2 emacs/lisp/calc/calc-sel.el:1.4.4.3
*** emacs/lisp/calc/calc-sel.el:1.4.4.2 Tue Oct 14 23:35:48 2003
--- emacs/lisp/calc/calc-sel.el Wed Dec  8 23:36:21 2004
***************
*** 3,10 ****
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainers: D. Goel <address@hidden>
! ;;              Colin Walters <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
--- 3,9 ----
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainer: Jay Belanger <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
***************
*** 28,44 ****
  ;;; Code:
  
  ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
  
  (require 'calc-macs)
  
- (defun calc-Need-calc-sel () nil)
- 
- 
  ;;; Selection commands.
  
  (defvar calc-keep-selection t)
  
  (defun calc-select-here (num &optional once keep)
    (interactive "P")
    (calc-wrapper
--- 27,46 ----
  ;;; Code:
  
  ;; This file is autoloaded from calc-ext.el.
  
+ (require 'calc-ext)
  (require 'calc-macs)
  
  ;;; Selection commands.
  
  (defvar calc-keep-selection t)
  
+ (defvar calc-selection-cache-entry nil)
+ (defvar calc-selection-cache-num)
+ (defvar calc-selection-cache-comp)
+ (defvar calc-selection-cache-offset)
+ (defvar calc-selection-true-num)
+ 
  (defun calc-select-here (num &optional once keep)
    (interactive "P")
    (calc-wrapper
***************
*** 141,166 ****
         (calc-change-current-selection sel)
         (error "%d is not a valid sub-formula index" num)))))
  
! (defun calc-find-nth-part (expr num)
    (if (and calc-assoc-selections
           (assq (car-safe expr) calc-assoc-ops))
!       (let (op)
        (calc-find-nth-part-rec expr))
      (if (eq (car-safe expr) 'intv)
!       (and (>= num 1) (<= num 2) (nth (1+ num) expr))
!       (and (not (Math-primp expr)) (>= num 1) (< num (length expr))
!          (nth num expr)))))
  
  (defun calc-find-nth-part-rec (expr)   ; uses num, op
!   (or (if (and (setq op (assq (car-safe (nth 1 expr)) calc-assoc-ops))
!              (memq (car expr) (nth 1 op)))
          (calc-find-nth-part-rec (nth 1 expr))
!       (and (= (setq num (1- num)) 0)
             (nth 1 expr)))
!       (if (and (setq op (assq (car-safe (nth 2 expr)) calc-assoc-ops))
!              (memq (car expr) (nth 2 op)))
          (calc-find-nth-part-rec (nth 2 expr))
!       (and (= (setq num (1- num)) 0)
             (nth 2 expr)))))
  
  (defun calc-select-next (num)
--- 143,174 ----
         (calc-change-current-selection sel)
         (error "%d is not a valid sub-formula index" num)))))
  
! ;; The variables calc-fnp-op and calc-fnp-num are local to 
! ;; calc-find-nth-part (and calc-select-previous) but used by 
! ;; calc-find-nth-part-rec, which is called by them.
! (defvar calc-fnp-op)
! (defvar calc-fnp-num)
! 
! (defun calc-find-nth-part (expr calc-fnp-num)
    (if (and calc-assoc-selections
           (assq (car-safe expr) calc-assoc-ops))
!       (let (calc-fnp-op)
        (calc-find-nth-part-rec expr))
      (if (eq (car-safe expr) 'intv)
!       (and (>= calc-fnp-num 1) (<= calc-fnp-num 2) (nth (1+ calc-fnp-num) 
expr))
!       (and (not (Math-primp expr)) (>= calc-fnp-num 1) (< calc-fnp-num 
(length expr))
!          (nth calc-fnp-num expr)))))
  
  (defun calc-find-nth-part-rec (expr)   ; uses num, op
!   (or (if (and (setq calc-fnp-op (assq (car-safe (nth 1 expr)) 
calc-assoc-ops))
!              (memq (car expr) (nth 1 calc-fnp-op)))
          (calc-find-nth-part-rec (nth 1 expr))
!       (and (= (setq calc-fnp-num (1- calc-fnp-num)) 0)
             (nth 1 expr)))
!       (if (and (setq calc-fnp-op (assq (car-safe (nth 2 expr)) 
calc-assoc-ops))
!              (memq (car expr) (nth 2 calc-fnp-op)))
          (calc-find-nth-part-rec (nth 2 expr))
!       (and (= (setq calc-fnp-num (1- calc-fnp-num)) 0)
             (nth 2 expr)))))
  
  (defun calc-select-next (num)
***************
*** 239,247 ****
             (calc-change-current-selection (car entry))
           (let ((len (if (and calc-assoc-selections
                               (assq (car (car entry)) calc-assoc-ops))
!                         (let (op (num 0))
                            (calc-find-nth-part-rec (car entry))
!                           (- 1 num))
                        (length (car entry)))))
             (calc-select-part (- len num)))))))))
  
--- 247,255 ----
             (calc-change-current-selection (car entry))
           (let ((len (if (and calc-assoc-selections
                               (assq (car (car entry)) calc-assoc-ops))
!                         (let (calc-fnp-op (calc-fnp-num 0))
                            (calc-find-nth-part-rec (car entry))
!                           (- 1 calc-fnp-num))
                        (length (car entry)))))
             (calc-select-part (- len num)))))))))
  
***************
*** 326,331 ****
--- 334,344 ----
                "Displaying only 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.
+ (defvar calc-final-point-line)
+ (defvar calc-final-point-column)
+ 
  (defun calc-preserve-point ()
    (or (looking-at "\\.\n+\\'")
        (progn
***************
*** 357,363 ****
                "Selection treats a+b+c as a sum of three terms"
              "Selection treats a+b+c as (a+b)+c"))))
  
- (defvar calc-selection-cache-entry nil)
  (defun calc-prepare-selection (&optional num)
    (or num (setq num (calc-locate-cursor-element (point))))
    (setq calc-selection-true-num num
--- 370,375 ----
***************
*** 400,405 ****
--- 412,421 ----
              (setcar x (list 'cplx (car x) 0))
            (calc-encase-atoms-rec (car x)))))))
  
+ ;; The variable math-comp-sel-tag is local to calc-find-selected-part,
+ ;; but is used by math-comp-sel-flat-term and math-comp-add-string-sel
+ ;; in calccomp.el, which are called (indirectly) by calc-find-selected-part.
+ 
  (defun calc-find-selected-part ()
    (let* ((math-comp-sel-hpos (- (current-column) calc-selection-cache-offset))
         toppt
***************
*** 456,467 ****
             (setq top (cdr top)))
           sel))))
  
! (defun calc-replace-sub-formula (expr old new)
!   (setq new (calc-encase-atoms new))
    (calc-replace-sub-formula-rec expr))
  
  (defun calc-replace-sub-formula-rec (expr)
!   (cond ((eq expr old) new)
        ((Math-primp expr) expr)
        (t
         (cons (car expr)
--- 472,489 ----
             (setq top (cdr top)))
           sel))))
  
! ;; The variables calc-rsf-old and calc-rsf-new are local to
! ;; calc-replace-sub-formula, but used by calc-replace-sub-formula-rec,
! ;; which is called by calc-replace-sub-formula.
! (defvar calc-rsf-old)
! (defvar calc-rsf-new)
! 
! (defun calc-replace-sub-formula (expr calc-rsf-old calc-rsf-new)
!   (setq calc-rsf-new (calc-encase-atoms calc-rsf-new))
    (calc-replace-sub-formula-rec expr))
  
  (defun calc-replace-sub-formula-rec (expr)
!   (cond ((eq expr calc-rsf-old) calc-rsf-new)
        ((Math-primp expr) expr)
        (t
         (cons (car expr)
***************
*** 581,590 ****
                      (calc-top-list m (- n m -1) 'sel))))
      (calc-pop-push-list n vals 1 sels)))
  
  (defun calc-auto-selection (entry)
    (or (nth 2 entry)
        (progn
!       (and (boundp 'reselect) (setq reselect nil))
        (calc-prepare-selection)
        (calc-grow-assoc-formula (car entry) (calc-find-selected-part)))))
  
--- 603,616 ----
                      (calc-top-list m (- n m -1) 'sel))))
      (calc-pop-push-list n vals 1 sels)))
  
+ ;; The variable calc-sel-reselect is local to several functions
+ ;; which call calc-auto-selection.
+ (defvar calc-sel-reselect)
+ 
  (defun calc-auto-selection (entry)
    (or (nth 2 entry)
        (progn
!       (setq calc-sel-reselect nil)
        (calc-prepare-selection)
        (calc-grow-assoc-formula (car entry) (calc-find-selected-part)))))
  
***************
*** 611,617 ****
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
--- 637,643 ----
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
***************
*** 626,632 ****
                                         (list (calc-replace-sub-formula
                                                expr sel alg))
                                         num
!                                        (list (and reselect alg))))))
       (calc-handle-whys))))
  
  (defun calc-edit-selection ()
--- 652,658 ----
                                         (list (calc-replace-sub-formula
                                                expr sel alg))
                                         num
!                                        (list (and calc-sel-reselect alg))))))
       (calc-handle-whys))))
  
  (defun calc-edit-selection ()
***************
*** 634,640 ****
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
--- 660,666 ----
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
***************
*** 642,651 ****
       (let ((str (math-showing-full-precision
                 (math-format-nice-expr sel (frame-width)))))
         (calc-edit-mode (list 'calc-finish-selection-edit
!                            num (list 'quote sel) reselect))
         (insert str "\n"))))
    (calc-show-edit-buffer))
  
  (defun calc-finish-selection-edit (num sel reselect)
    (let ((buf (current-buffer))
        (str (buffer-substring (point) (point-max)))
--- 668,683 ----
       (let ((str (math-showing-full-precision
                 (math-format-nice-expr sel (frame-width)))))
         (calc-edit-mode (list 'calc-finish-selection-edit
!                            num (list 'quote sel) calc-sel-reselect))
         (insert str "\n"))))
    (calc-show-edit-buffer))
  
+ (defvar calc-original-buffer)
+ 
+ ;; The variable calc-edit-disp-trail is local to calc-edit-finish,
+ ;; in calc-yank.el.
+ (defvar calc-edit-disp-trail)
+ 
  (defun calc-finish-selection-edit (num sel reselect)
    (let ((buf (current-buffer))
        (str (buffer-substring (point) (point-max)))
***************
*** 659,665 ****
            (error (nth 2 val))))
        (calc-wrapper
         (calc-preserve-point)
!        (if disp-trail
           (calc-trail-display 1 t))
         (setq val (calc-encase-atoms (calc-normalize val)))
         (let ((expr (calc-top num 'full)))
--- 691,697 ----
            (error (nth 2 val))))
        (calc-wrapper
         (calc-preserve-point)
!        (if calc-edit-disp-trail
           (calc-trail-display 1 t))
         (setq val (calc-encase-atoms (calc-normalize val)))
         (let ((expr (calc-top num 'full)))
***************
*** 677,683 ****
    (calc-slow-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (sel (or (calc-auto-selection entry) (car entry))))
       (calc-with-default-simplification
--- 709,715 ----
    (calc-slow-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (sel (or (calc-auto-selection entry) (car entry))))
       (calc-with-default-simplification
***************
*** 688,694 ****
                                     (list (calc-replace-sub-formula
                                            (car entry) sel val))
                                     num
!                                    (list (and reselect val))))))
       (calc-handle-whys))))
  
  (defun calc-sel-expand-formula (arg)
--- 720,726 ----
                                     (list (calc-replace-sub-formula
                                            (car entry) sel val))
                                     num
!                                    (list (and calc-sel-reselect val))))))
       (calc-handle-whys))))
  
  (defun calc-sel-expand-formula (arg)
***************
*** 696,702 ****
    (calc-slow-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (sel (or (calc-auto-selection entry) (car entry))))
       (calc-with-default-simplification
--- 728,734 ----
    (calc-slow-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (sel (or (calc-auto-selection entry) (car entry))))
       (calc-with-default-simplification
***************
*** 713,719 ****
                                     (list (calc-replace-sub-formula
                                            (car entry) sel val))
                                     num
!                                    (list (and reselect val))))))
       (calc-handle-whys))))
  
  (defun calc-sel-mult-both-sides (no-simp &optional divide)
--- 745,751 ----
                                     (list (calc-replace-sub-formula
                                            (car entry) sel val))
                                     num
!                                    (list (and calc-sel-reselect val))))))
       (calc-handle-whys))))
  
  (defun calc-sel-mult-both-sides (no-simp &optional divide)
***************
*** 721,727 ****
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
--- 753,759 ----
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
***************
*** 774,780 ****
                                       (list (calc-replace-sub-formula
                                              expr sel alg))
                                       num
!                                      (list (and reselect alg)))))
       (calc-handle-whys))))
  
  (defun calc-sel-div-both-sides (no-simp)
--- 806,812 ----
                                       (list (calc-replace-sub-formula
                                              expr sel alg))
                                       num
!                                      (list (and calc-sel-reselect alg)))))
       (calc-handle-whys))))
  
  (defun calc-sel-div-both-sides (no-simp)
***************
*** 786,792 ****
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
--- 818,824 ----
    (calc-wrapper
     (calc-preserve-point)
     (let* ((num (max 1 (calc-locate-cursor-element (point))))
!         (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
          (sel (or (calc-auto-selection entry) expr))
***************
*** 818,829 ****
                                       (list (calc-replace-sub-formula
                                              expr sel alg))
                                       num
!                                      (list (and reselect alg)))))
       (calc-handle-whys))))
  
  (defun calc-sel-sub-both-sides (no-simp)
    (interactive "P")
    (calc-sel-add-both-sides no-simp t))
  
  ;;; arch-tag: e5169792-777d-428f-bff5-acca66813fa2
  ;;; calc-sel.el ends here
--- 850,863 ----
                                       (list (calc-replace-sub-formula
                                              expr sel alg))
                                       num
!                                      (list (and calc-sel-reselect alg)))))
       (calc-handle-whys))))
  
  (defun calc-sel-sub-both-sides (no-simp)
    (interactive "P")
    (calc-sel-add-both-sides no-simp t))
  
+ (provide 'calc-sel)
+ 
  ;;; arch-tag: e5169792-777d-428f-bff5-acca66813fa2
  ;;; calc-sel.el ends here




reply via email to

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