aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Yavner2008-05-15 19:24:57 +0000
committerJonathan Yavner2008-05-15 19:24:57 +0000
commitc0c30dd15f9f66e5d5422eb9d04d22329187fc20 (patch)
tree43f79ae3265c0d771869cac401e8d0505561f888
parent370fded4f6cc9c10c776733a1944b1faab84e2bd (diff)
downloademacs-c0c30dd15f9f66e5d5422eb9d04d22329187fc20.tar.gz
emacs-c0c30dd15f9f66e5d5422eb9d04d22329187fc20.zip
* ses.el (ses-goto-print): Use move-to-column rather than
forward-char. (ses-print-cell): Use string-width, truncate-string-to-width, delete-region rather than length, substring, delete-char. (ses-setup): Set inhibit-point-motion-hooks to t. Calculate position by actually moving point rather than just using unibyte character length. (ses-mode): Set indent-tabs-mode to nil. (ses-center): Use string-width rather than length.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/ses.el39
2 files changed, 43 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6504f1cfdbf..bec5c389e1c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12008-05-15 Shigeru Fukaya <shugeru.fukaya@gmail.com>
2
3 * ses.el (ses-goto-print): Use move-to-column rather than
4 forward-char.
5 (ses-print-cell): Use string-width, truncate-string-to-width,
6 delete-region rather than length, substring, delete-char.
7 (ses-setup): Set inhibit-point-motion-hooks to t. Calculate
8 position by actually moving point rather than just using unibyte
9 character length.
10 (ses-mode): Set indent-tabs-mode to nil.
11 (ses-center): Use string-width rather than length.
12
12008-05-15 Eric S. Raymond <esr@snark.thyrsus.com> 132008-05-15 Eric S. Raymond <esr@snark.thyrsus.com>
2 14
3 * vc-cvs.el, vc-git.el, vc-hg.el, vc-hooks.el, vc-mcvs.el, 15 * vc-cvs.el, vc-git.el, vc-hg.el, vc-hooks.el, vc-mcvs.el,
diff --git a/lisp/ses.el b/lisp/ses.el
index 64b966bfa91..4bd88975c58 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -726,11 +726,18 @@ if the cell's value is unchanged and FORCE is nil."
726;;ses-goto-print is called during a recursive ses-print-cell). 726;;ses-goto-print is called during a recursive ses-print-cell).
727(defun ses-goto-print (row col) 727(defun ses-goto-print (row col)
728 "Move point to print area for cell (ROW,COL)." 728 "Move point to print area for cell (ROW,COL)."
729 (let ((inhibit-point-motion-hooks t)) 729 (let ((inhibit-point-motion-hooks t)
730 (n 0))
730 (goto-char (point-min)) 731 (goto-char (point-min))
731 (forward-line row) 732 (forward-line row)
733 ;; calculate column position
732 (dotimes (c col) 734 (dotimes (c col)
733 (forward-char (1+ (ses-col-width c)))))) 735 (setq n (+ n (ses-col-width c) 1)))
736 ;; move to the position
737 (and (> n (move-to-column n))
738 (eolp)
739 ;; move point to the bol of next line (for TAB at the last cell)
740 (forward-char))))
734 741
735(defun ses-set-curcell () 742(defun ses-set-curcell ()
736 "Sets `ses--curcell' to the current cell symbol, or a cons (BEG,END) for a 743 "Sets `ses--curcell' to the current cell symbol, or a cons (BEG,END) for a
@@ -806,7 +813,7 @@ preceding cell has spilled over."
806 (setq sig ses-call-printer-return)))) 813 (setq sig ses-call-printer-return))))
807 ;;Adjust print width to match column width 814 ;;Adjust print width to match column width
808 (let ((width (ses-col-width col)) 815 (let ((width (ses-col-width col))
809 (len (length text))) 816 (len (string-width text)))
810 (cond 817 (cond
811 ((< len width) 818 ((< len width)
812 ;;Fill field to length with spaces 819 ;;Fill field to length with spaces
@@ -834,7 +841,7 @@ preceding cell has spilled over."
834 (setq sig `(error "Too wide" ,text)) 841 (setq sig `(error "Too wide" ,text))
835 (cond 842 (cond
836 ((stringp value) 843 ((stringp value)
837 (setq text (substring text 0 maxwidth))) 844 (setq text (truncate-string-to-width text maxwidth 0 ?\s)))
838 ((and (numberp value) 845 ((and (numberp value)
839 (string-match "\\.[0-9]+" text) 846 (string-match "\\.[0-9]+" text)
840 (>= 0 (setq width 847 (>= 0 (setq width
@@ -855,7 +862,11 @@ preceding cell has spilled over."
855 ;;Install the printed result. This is not interruptible. 862 ;;Install the printed result. This is not interruptible.
856 (let ((inhibit-read-only t) 863 (let ((inhibit-read-only t)
857 (inhibit-quit t)) 864 (inhibit-quit t))
858 (delete-char (1+ (length text))) 865 (let ((inhibit-point-motion-hooks t))
866 (delete-region (point) (progn
867 (move-to-column (+ (current-column)
868 (string-width text)))
869 (1+ (point)))))
859 ;;We use concat instead of inserting separate strings in order to 870 ;;We use concat instead of inserting separate strings in order to
860 ;;reduce the number of cells in the undo list. 871 ;;reduce the number of cells in the undo list.
861 (setq x (concat text (if (< maxcol ses--numcols) " " "\n"))) 872 (setq x (concat text (if (< maxcol ses--numcols) " " "\n")))
@@ -1443,6 +1454,7 @@ Narrows the buffer to show only the print area. Gives it `read-only' and
1443 (interactive) 1454 (interactive)
1444 (let ((end (point-min)) 1455 (let ((end (point-min))
1445 (inhibit-read-only t) 1456 (inhibit-read-only t)
1457 (inhibit-point-motion-hooks t)
1446 (was-modified (buffer-modified-p)) 1458 (was-modified (buffer-modified-p))
1447 pos sym) 1459 pos sym)
1448 (ses-goto-data 0 0) ;;Include marker between print-area and data-area 1460 (ses-goto-data 0 0) ;;Include marker between print-area and data-area
@@ -1466,7 +1478,14 @@ Narrows the buffer to show only the print area. Gives it `read-only' and
1466 (eq (ses-cell-value row (1+ col)) '*skip*)) 1478 (eq (ses-cell-value row (1+ col)) '*skip*))
1467 (setq end (+ end (ses-col-width col) 1) 1479 (setq end (+ end (ses-col-width col) 1)
1468 col (1+ col))) 1480 col (1+ col)))
1469 (setq end (+ end (ses-col-width col) 1)) 1481 (setq end (save-excursion
1482 (goto-char pos)
1483 (move-to-column (+ (current-column) (- end pos)
1484 (ses-col-width col)))
1485 (if (eolp)
1486 (+ end (ses-col-width col) 1)
1487 (forward-char)
1488 (point))))
1470 (put-text-property pos end 'intangible sym))) 1489 (put-text-property pos end 'intangible sym)))
1471 ;;Adding these properties did not actually alter the text 1490 ;;Adding these properties did not actually alter the text
1472 (unless was-modified 1491 (unless was-modified
@@ -1519,7 +1538,10 @@ These are active only in the minibuffer, when entering or editing a formula:
1519 ;;SES deliberately puts lots of trailing whitespace in its buffer 1538 ;;SES deliberately puts lots of trailing whitespace in its buffer
1520 show-trailing-whitespace nil 1539 show-trailing-whitespace nil
1521 ;;Cell ranges do not work reasonably without this 1540 ;;Cell ranges do not work reasonably without this
1522 transient-mark-mode t) 1541 transient-mark-mode t
1542 ;;not to use tab characters for safe
1543 ;;(tabs may do bad for column calculation)
1544 indent-tabs-mode nil)
1523 (1value (add-hook 'change-major-mode-hook 'ses-cleanup nil t)) 1545 (1value (add-hook 'change-major-mode-hook 'ses-cleanup nil t))
1524 (1value (add-hook 'before-revert-hook 'ses-cleanup nil t)) 1546 (1value (add-hook 'before-revert-hook 'ses-cleanup nil t))
1525 (setq ses--curcell nil 1547 (setq ses--curcell nil
@@ -2938,7 +2960,8 @@ columns to include in width (default = 0)."
2938 (setq value (ses-call-printer printer value)) 2960 (setq value (ses-call-printer printer value))
2939 (dotimes (x span) 2961 (dotimes (x span)
2940 (setq width (+ width 1 (ses-col-width (+ col span (- x)))))) 2962 (setq width (+ width 1 (ses-col-width (+ col span (- x))))))
2941 (setq width (- width (length value))) 2963 ;; set column width
2964 (setq width (- width (string-width value)))
2942 (if (<= width 0) 2965 (if (<= width 0)
2943 value ;Too large for field, anyway 2966 value ;Too large for field, anyway
2944 (setq half (make-string (/ width 2) fill)) 2967 (setq half (make-string (/ width 2) fill))