2021-04-19 10:21:01 +00:00
|
|
|
|
;;; ses.el --- Simple Emacs Spreadsheet -*- lexical-binding:t -*-
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2022-01-01 07:45:51 +00:00
|
|
|
|
;; Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2003-07-25 04:59:09 +00:00
|
|
|
|
;; Author: Jonathan Yavner <jyavner@member.fsf.org>
|
2019-05-20 04:29:13 +00:00
|
|
|
|
;; Maintainer: Vincent Belaïche <vincentb1@users.sourceforge.net>
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Keywords: spreadsheet Dijkstra
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;; To-do list:
|
2004-11-22 01:21:07 +00:00
|
|
|
|
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
;; * M-w should deactivate the mark.
|
|
|
|
|
;; * offer some way to use absolute cell addressing.
|
|
|
|
|
;; * Maybe some way to copy a reference to a cell's formula rather than the
|
|
|
|
|
;; formula itself.
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;; * split (catch 'cycle ...) call back into one or more functions
|
2004-02-14 23:56:51 +00:00
|
|
|
|
;; * Use $ or … for truncated fields
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
;; * M-t to transpose 2 columns.
|
|
|
|
|
;; * M-d should kill the cell under point.
|
|
|
|
|
;; * C-t to transpose 2 rows.
|
|
|
|
|
;; * C-k and M-k should be ses-kill-row and ses-kill-column.
|
|
|
|
|
;; * C-o should insert the row below point rather than above?
|
|
|
|
|
;; * rows inserted with C-o should inherit formulas from surrounding rows.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
;; * Add command to make a range of columns be temporarily invisible.
|
|
|
|
|
;; * Allow paste of one cell to a range of cells -- copy formula to each.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;; * Do something about control characters & octal codes in cell print
|
2004-02-14 23:56:51 +00:00
|
|
|
|
;; areas. Use string-width?
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;; * Input validation functions. How specified?
|
|
|
|
|
;; * Faces (colors & styles) in print cells.
|
|
|
|
|
;; * Move a column by dragging its letter in the header line.
|
|
|
|
|
;; * Left-margin column for row number.
|
|
|
|
|
;; * Move a row by dragging its number in the left-margin.
|
|
|
|
|
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;;; Cycle detection
|
|
|
|
|
|
|
|
|
|
;; Cycles used to be detected by stationarity of ses--deferred-recalc. This was
|
|
|
|
|
;; working fine in most cases, however failed in some cases of several path
|
|
|
|
|
;; racing together.
|
|
|
|
|
;;
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
;; The current algorithm is based on Dijkstra's algorithm. The cycle length is
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;; stored in some cell property. In order not to reset in all cells such
|
|
|
|
|
;; property at each update, the cycle length is stored in this property along
|
|
|
|
|
;; with some update attempt id that is incremented at each update. The current
|
|
|
|
|
;; update id is ses--Dijkstra-attempt-nb. In case there is a cycle the cycle
|
|
|
|
|
;; length diverge to infinite so it will exceed ses--Dijkstra-weight-bound at
|
|
|
|
|
;; some point of time that allows detection. Otherwise it converges to the
|
|
|
|
|
;; longest path length in the update tree.
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(require 'unsafep)
|
2014-10-25 10:40:14 +00:00
|
|
|
|
(require 'macroexp)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; User-customizable variables
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defgroup ses nil
|
2005-07-04 02:27:03 +00:00
|
|
|
|
"Simple Emacs Spreadsheet."
|
2012-04-22 13:58:00 +00:00
|
|
|
|
:tag "SES"
|
2002-09-28 18:45:56 +00:00
|
|
|
|
:group 'applications
|
2014-01-25 19:15:42 +00:00
|
|
|
|
:link '(custom-manual "(ses) Top")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
:prefix "ses-"
|
|
|
|
|
:version "21.1")
|
|
|
|
|
|
|
|
|
|
(defcustom ses-initial-size '(1 . 1)
|
|
|
|
|
"Initial size of a new spreadsheet, as a cons (NUMROWS . NUMCOLS)."
|
|
|
|
|
:type '(cons (integer :tag "numrows") (integer :tag "numcols")))
|
|
|
|
|
|
2004-01-30 08:02:57 +00:00
|
|
|
|
(defcustom ses-initial-column-width 7
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Initial width of columns in a new spreadsheet."
|
|
|
|
|
:type '(integer :match (lambda (widget value) (> value 0))))
|
|
|
|
|
|
|
|
|
|
(defcustom ses-initial-default-printer "%.7g"
|
|
|
|
|
"Initial default printer for a new spreadsheet."
|
|
|
|
|
:type '(choice string
|
|
|
|
|
(list :tag "Parenthesized string" string)
|
|
|
|
|
function))
|
|
|
|
|
|
|
|
|
|
(defcustom ses-after-entry-functions '(forward-char)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Things to do after entering a value into a cell.
|
|
|
|
|
An abnormal hook that usually runs a cursor-movement function.
|
|
|
|
|
Each function is called with ARG=1."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:options '(forward-char backward-char next-line previous-line))
|
|
|
|
|
|
|
|
|
|
(defcustom ses-mode-hook nil
|
|
|
|
|
"Hook functions to be run upon entering SES mode."
|
|
|
|
|
:type 'hook)
|
|
|
|
|
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(defcustom ses-jump-cell-name-function #'upcase
|
|
|
|
|
"Function to process the string passed to function ‘ses-jump’.
|
|
|
|
|
Set it to 'identity to make no change.
|
2022-04-04 17:42:07 +00:00
|
|
|
|
Set it to 'upcase to make cell name change case isensitive.
|
|
|
|
|
|
|
|
|
|
May return
|
|
|
|
|
|
|
|
|
|
* a string, in this case this must be a cell name.
|
|
|
|
|
* a (row . col) cons cell, in this case that must be valid cell coordinate."
|
|
|
|
|
:type 'function)
|
|
|
|
|
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(defcustom ses-jump-prefix-function #'ses-jump-prefix
|
|
|
|
|
"Function that takes the prefix argument passed to function ‘ses-jump’.
|
|
|
|
|
It may return the same sort of thing as ‘ses-jump-cell-name-function’."
|
2022-04-04 17:42:07 +00:00
|
|
|
|
:type 'function)
|
|
|
|
|
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Global variables and constants
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defvar ses-read-cell-history nil
|
|
|
|
|
"List of formulas that have been typed in.")
|
|
|
|
|
|
|
|
|
|
(defvar ses-read-printer-history nil
|
|
|
|
|
"List of printer functions that have been typed in.")
|
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(easy-menu-define ses-header-line-menu nil
|
|
|
|
|
"Context menu when mouse-3 is used on the header-line in an SES buffer."
|
|
|
|
|
'("SES header row"
|
|
|
|
|
["Set current row" ses-set-header-row t]
|
2004-11-22 01:21:07 +00:00
|
|
|
|
["Unset row" ses-unset-header-row (> ses--header-row 0)]))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(defconst ses-mode-map
|
|
|
|
|
(let ((keys `("\C-c\M-\C-l" ses-reconstruct-all
|
|
|
|
|
"\C-c\C-l" ses-recalculate-all
|
|
|
|
|
"\C-c\C-n" ses-renarrow-buffer
|
|
|
|
|
"\C-c\C-c" ses-recalculate-cell
|
|
|
|
|
"\C-c\M-\C-s" ses-sort-column
|
|
|
|
|
"\C-c\M-\C-h" ses-set-header-row
|
|
|
|
|
"\C-c\C-t" ses-truncate-cell
|
|
|
|
|
"\C-c\C-j" ses-jump
|
|
|
|
|
"\C-c\C-p" ses-read-default-printer
|
|
|
|
|
"\M-\C-l" ses-reprint-all
|
|
|
|
|
[?\S-\C-l] ses-reprint-all
|
|
|
|
|
[header-line down-mouse-3] ,ses-header-line-menu
|
|
|
|
|
[header-line mouse-2] ses-sort-column-click))
|
|
|
|
|
(newmap (make-sparse-keymap)))
|
|
|
|
|
(while keys
|
|
|
|
|
(define-key (1value newmap) (car keys) (cadr keys))
|
|
|
|
|
(setq keys (cddr keys)))
|
|
|
|
|
newmap)
|
|
|
|
|
"Local keymap for Simple Emacs Spreadsheet.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(easy-menu-define ses-menu ses-mode-map
|
|
|
|
|
"Menu bar menu for SES."
|
|
|
|
|
'("SES"
|
|
|
|
|
["Insert row" ses-insert-row (ses-in-print-area)]
|
|
|
|
|
["Delete row" ses-delete-row (ses-in-print-area)]
|
|
|
|
|
["Insert column" ses-insert-column (ses-in-print-area)]
|
|
|
|
|
["Delete column" ses-delete-column (ses-in-print-area)]
|
|
|
|
|
["Set column printer" ses-read-column-printer t]
|
|
|
|
|
["Set column width" ses-set-column-width t]
|
|
|
|
|
["Set default printer" ses-read-default-printer t]
|
|
|
|
|
["Jump to cell" ses-jump t]
|
|
|
|
|
["Set cell printer" ses-read-cell-printer t]
|
|
|
|
|
["Recalculate cell" ses-recalculate-cell t]
|
|
|
|
|
["Truncate cell display" ses-truncate-cell t]
|
|
|
|
|
["Export values" ses-export-tsv t]
|
|
|
|
|
["Export formulas" ses-export-tsf t]))
|
|
|
|
|
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(defconst ses-completion-keys '("\M-\C-i" "\C-i")
|
|
|
|
|
"List for keys that can be used for completion while editing.")
|
|
|
|
|
|
|
|
|
|
(defvar ses--completion-table nil
|
|
|
|
|
"Set globally to what completion table to use depending on type
|
2021-04-25 11:12:48 +00:00
|
|
|
|
of completion (local printers, cells, etc.). We need to go
|
|
|
|
|
through a local variable to pass the SES buffer local variable
|
|
|
|
|
to completing function while the current buffer is the
|
|
|
|
|
minibuffer.")
|
2017-07-17 17:58:12 +00:00
|
|
|
|
|
|
|
|
|
(defvar ses--list-orig-buffer nil
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Calling buffer for SES listing help.
|
|
|
|
|
Used for listing local printers or renamed cells.")
|
2017-07-17 17:58:12 +00:00
|
|
|
|
|
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(defconst ses-mode-edit-map
|
|
|
|
|
(let ((keys '("\C-c\C-r" ses-insert-range
|
|
|
|
|
"\C-c\C-s" ses-insert-ses-range
|
|
|
|
|
[S-mouse-3] ses-insert-range-click
|
|
|
|
|
[C-S-mouse-3] ses-insert-ses-range-click
|
2017-07-17 17:58:12 +00:00
|
|
|
|
"\C-h\C-p" ses-list-local-printers
|
|
|
|
|
"\C-h\C-n" ses-list-named-cells
|
|
|
|
|
"\M-\C-i" lisp-complete-symbol)) ; redefined
|
|
|
|
|
; dynamically in
|
|
|
|
|
; editing
|
|
|
|
|
; functions
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(newmap (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent newmap minibuffer-local-map)
|
|
|
|
|
(while keys
|
2006-01-23 22:04:36 +00:00
|
|
|
|
(define-key newmap (pop keys) (pop keys)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
newmap)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Local keymap for SES minibuffer cell-editing.")
|
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
;Local keymap for SES print area
|
|
|
|
|
(defalias 'ses-mode-print-map
|
|
|
|
|
(let ((keys '([backtab] backward-char
|
|
|
|
|
[tab] ses-forward-or-insert
|
2011-06-27 05:41:58 +00:00
|
|
|
|
"\C-i" ses-forward-or-insert ; Needed for ses-coverage.el?
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"\M-o" ses-insert-column
|
|
|
|
|
"\C-o" ses-insert-row
|
|
|
|
|
"\C-m" ses-edit-cell
|
|
|
|
|
"\M-k" ses-delete-column
|
|
|
|
|
"\M-y" ses-yank-pop
|
|
|
|
|
"\C-k" ses-delete-row
|
|
|
|
|
"\C-j" ses-append-row-jump-first-column
|
|
|
|
|
"\M-h" ses-mark-row
|
|
|
|
|
"\M-H" ses-mark-column
|
|
|
|
|
"\C-d" ses-clear-cell-forward
|
|
|
|
|
"\C-?" ses-clear-cell-backward
|
|
|
|
|
"(" ses-read-cell
|
|
|
|
|
"\"" ses-read-cell
|
|
|
|
|
"'" ses-read-symbol
|
|
|
|
|
"=" ses-edit-cell
|
2007-10-25 20:12:26 +00:00
|
|
|
|
"c" ses-recalculate-cell
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"j" ses-jump
|
|
|
|
|
"p" ses-read-cell-printer
|
2007-10-25 20:12:26 +00:00
|
|
|
|
"t" ses-truncate-cell
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"w" ses-set-column-width
|
|
|
|
|
"x" ses-export-keymap
|
|
|
|
|
"\M-p" ses-read-column-printer))
|
|
|
|
|
(numeric "0123456789.-")
|
|
|
|
|
(newmap (make-keymap)))
|
|
|
|
|
;;Get rid of printables
|
|
|
|
|
(suppress-keymap newmap t)
|
|
|
|
|
;;These keys insert themselves as the beginning of a numeric value
|
|
|
|
|
(dotimes (x (length numeric))
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(define-key newmap (substring numeric x (1+ x)) #'ses-read-cell))
|
2021-12-16 02:14:31 +00:00
|
|
|
|
(define-key newmap [remap clipboard-kill-region] #'ses-kill-override)
|
|
|
|
|
(define-key newmap [remap end-of-line] #'ses-end-of-line)
|
|
|
|
|
(define-key newmap [remap kill-line] #'ses-delete-row)
|
|
|
|
|
(define-key newmap [remap kill-region] #'ses-kill-override)
|
|
|
|
|
(define-key newmap [remap open-line] #'ses-insert-row)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
;;Define our other local keys
|
|
|
|
|
(while keys
|
|
|
|
|
(define-key newmap (car keys) (cadr keys))
|
|
|
|
|
(setq keys (cddr keys)))
|
|
|
|
|
newmap))
|
|
|
|
|
|
|
|
|
|
;;Helptext for ses-mode wants keymap as variable, not function
|
|
|
|
|
(defconst ses-mode-print-map (symbol-function 'ses-mode-print-map))
|
|
|
|
|
|
|
|
|
|
;;Key map used for 'x' key.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defalias 'ses-export-keymap
|
|
|
|
|
(let ((map (make-sparse-keymap "SES export")))
|
|
|
|
|
(define-key map "T" (cons " tab-formulas" 'ses-export-tsf))
|
|
|
|
|
(define-key map "t" (cons " tab-values" 'ses-export-tsv))
|
|
|
|
|
map))
|
|
|
|
|
|
|
|
|
|
(defconst ses-print-data-boundary "\n\014\n"
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Marker string denoting the boundary between print area and data area.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defconst ses-initial-global-parameters
|
|
|
|
|
"\n( ;Global parameters (these are read first)\n 2 ;SES file-format\n 1 ;numrows\n 1 ;numcols\n)\n\n"
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Initial contents for the three-element list at the bottom of the data area.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(defconst ses-initial-global-parameters-re
|
|
|
|
|
"\n( ;Global parameters (these are read first)\n [23] ;SES file-format\n [0-9]+ ;numrows\n [0-9]+ ;numcols\n\\( [0-9]+ ;numlocprn\n\\)?)\n\n"
|
|
|
|
|
"Match Global parameters for .")
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defconst ses-initial-file-trailer
|
2004-11-22 01:21:07 +00:00
|
|
|
|
";; Local Variables:\n;; mode: ses\n;; End:\n"
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Initial contents for the file-trailer area at the bottom of the file.")
|
|
|
|
|
|
|
|
|
|
(defconst ses-initial-file-contents
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(concat " \n" ; One blank cell in print area.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
ses-print-data-boundary
|
2011-06-27 05:41:58 +00:00
|
|
|
|
"(ses-cell A1 nil nil nil nil)\n" ; One blank cell in data area.
|
|
|
|
|
"\n" ; End-of-row terminator for the one row in data area.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"(ses-column-widths [7])\n"
|
|
|
|
|
"(ses-column-printers [nil])\n"
|
|
|
|
|
"(ses-default-printer \"%.7g\")\n"
|
|
|
|
|
"(ses-header-row 0)\n"
|
|
|
|
|
ses-initial-global-parameters
|
|
|
|
|
ses-initial-file-trailer)
|
|
|
|
|
"The initial contents of an empty spreadsheet.")
|
|
|
|
|
|
|
|
|
|
(defconst ses-box-prop '(:box (:line-width 2 :style released-button))
|
|
|
|
|
"Display properties to create a raised box for cells in the header line.")
|
|
|
|
|
|
|
|
|
|
(defconst ses-standard-printer-functions
|
2016-07-28 15:41:21 +00:00
|
|
|
|
'(ses-center
|
|
|
|
|
ses-center-span ses-dashfill ses-dashfill-span
|
|
|
|
|
ses-tildefill-span
|
|
|
|
|
ses-prin1)
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"List of print functions to be included in initial history of printer functions.
|
|
|
|
|
None of these standard-printer functions, except function
|
|
|
|
|
`ses-prin1', is suitable for use as a column printer or a
|
|
|
|
|
global-default printer because they invoke the column or default
|
|
|
|
|
printer and then modify its output.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2006-09-29 02:42:39 +00:00
|
|
|
|
|
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Local variables and constants
|
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
|
2014-01-03 14:18:24 +00:00
|
|
|
|
(eval-and-compile
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defconst ses-localvars
|
2011-06-27 06:02:27 +00:00
|
|
|
|
'(ses--blank-line ses--cells ses--col-printers
|
2011-06-29 18:37:31 +00:00
|
|
|
|
ses--col-widths ses--curcell ses--curcell-overlay
|
2011-06-27 06:02:27 +00:00
|
|
|
|
ses--default-printer
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(ses--local-printer-hashmap . :hashmap)
|
|
|
|
|
(ses--numlocprn . 0); count of local printers
|
2011-06-29 18:37:31 +00:00
|
|
|
|
ses--deferred-narrow ses--deferred-recalc
|
|
|
|
|
ses--deferred-write ses--file-format
|
2012-11-09 05:48:05 +00:00
|
|
|
|
ses--named-cell-hashmap
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses--header-hscroll . -1) ; Flag for "initial recalc needed"
|
|
|
|
|
ses--header-row ses--header-string ses--linewidth
|
|
|
|
|
ses--numcols ses--numrows ses--symbolic-formulas
|
2011-06-29 18:37:31 +00:00
|
|
|
|
ses--data-marker ses--params-marker (ses--Dijkstra-attempt-nb . 0)
|
|
|
|
|
ses--Dijkstra-weight-bound
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; This list is useful for clean-up of symbols when an area
|
|
|
|
|
;; containing renamed cell is deleted.
|
|
|
|
|
ses--in-killing-named-cell-list
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;; Global variables that we override
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
next-line-add-newlines transient-mark-mode)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
"Buffer-local variables used by SES."))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2021-03-11 18:11:40 +00:00
|
|
|
|
(defmacro ses--\,@ (exp) (declare (debug t)) (macroexp-progn (eval exp t)))
|
|
|
|
|
(ses--\,@
|
|
|
|
|
(mapcar (lambda (x) `(defvar ,(or (car-safe x) x))) ses-localvars))
|
2014-09-11 19:44:25 +00:00
|
|
|
|
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(defun ses-set-localvars ()
|
|
|
|
|
"Set buffer-local and initialize some SES variables."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dolist (x ses-localvars)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(cond
|
|
|
|
|
((symbolp x)
|
|
|
|
|
(set (make-local-variable x) nil))
|
|
|
|
|
((consp x)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(cond
|
|
|
|
|
((integerp (cdr x))
|
|
|
|
|
(set (make-local-variable (car x)) (cdr x)))
|
|
|
|
|
((eq (cdr x) :hashmap)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(set (make-local-variable (car x)) (make-hash-table :test 'eq)))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(t (error "Unexpected initializer `%S' in list `ses-localvars' for entry %S"
|
|
|
|
|
(cdr x) (car x)) ) ))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(t (error "Unexpected elements `%S' in list `ses-localvars'" x)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;;; This variable is documented as being permitted in file-locals:
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(put 'ses--symbolic-formulas 'safe-local-variable #'consp)
|
2007-10-25 20:12:26 +00:00
|
|
|
|
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(defconst ses-paramlines-plist
|
|
|
|
|
'(ses--col-widths -5 ses--col-printers -4 ses--default-printer -3
|
|
|
|
|
ses--header-row -2 ses--file-format 1 ses--numrows 2
|
2014-06-12 06:04:48 +00:00
|
|
|
|
ses--numcols 3 ses--numlocprn 4)
|
2015-11-17 23:28:50 +00:00
|
|
|
|
"Offsets from \"Global parameters\" line to various parameter lines in the
|
2006-09-29 02:42:39 +00:00
|
|
|
|
data area of a spreadsheet.")
|
|
|
|
|
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(defconst ses-paramfmt-plist
|
|
|
|
|
'(ses--col-widths "(ses-column-widths %S)"
|
|
|
|
|
ses--col-printers "(ses-column-printers %S)"
|
|
|
|
|
ses--default-printer "(ses-default-printer %S)"
|
|
|
|
|
ses--header-row "(ses-header-row %S)"
|
|
|
|
|
ses--file-format " %S ;SES file-format"
|
|
|
|
|
ses--numrows " %S ;numrows"
|
|
|
|
|
ses--numcols " %S ;numcols"
|
|
|
|
|
ses--numlocprn " %S ;numlocprn")
|
2015-11-17 23:28:50 +00:00
|
|
|
|
"Formats of \"Global parameters\" various parameters in the data
|
2014-06-12 06:04:48 +00:00
|
|
|
|
area of a spreadsheet.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;
|
|
|
|
|
;; "Side-effect variables". They are set in one function, altered in
|
|
|
|
|
;; another as a side effect, then read back by the first, as a way of
|
|
|
|
|
;; passing back more than one value. These declarations are just to make
|
2020-09-01 21:59:11 +00:00
|
|
|
|
;; the compiler happy, and to conform to standard Emacs Lisp practice (I
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;; think the make-local-variable trick above is cleaner).
|
|
|
|
|
;;
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defvar ses-relocate-return nil
|
|
|
|
|
"Set by `ses-relocate-formula' and `ses-relocate-range', read by
|
2015-11-17 23:28:50 +00:00
|
|
|
|
`ses-relocate-all'. Set to `delete' if a cell-reference was deleted from a
|
|
|
|
|
formula--so the formula needs recalculation. Set to `range' if the size of a
|
2002-09-28 18:45:56 +00:00
|
|
|
|
`ses-range' was changed--so both the formula's value and list of dependents
|
|
|
|
|
need to be recalculated.")
|
|
|
|
|
|
|
|
|
|
(defvar ses-call-printer-return nil
|
|
|
|
|
"Set to t if last cell printer invoked by `ses-call-printer' requested
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
left-justification of the result. Set to error-signal if `ses-call-printer'
|
2006-11-11 04:00:37 +00:00
|
|
|
|
encountered an error during printing. Otherwise nil.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defvar ses-start-time nil
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Time when current operation started.
|
|
|
|
|
Used by `ses--time-check' to decide when to emit a progress
|
|
|
|
|
message.")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Macros
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses-get-cell (row col)
|
|
|
|
|
"Return the cell structure that stores information about cell (ROW,COL)."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
`(aref (aref ses--cells ,row) ,col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-defstruct (ses-cell
|
|
|
|
|
(:constructor nil)
|
|
|
|
|
(:constructor ses-make-cell
|
|
|
|
|
(&optional symbol formula printer references))
|
|
|
|
|
(:copier nil)
|
|
|
|
|
;; This is treated as an 4-elem array in various places.
|
|
|
|
|
;; Mostly in ses-set-cell.
|
|
|
|
|
(:type vector) ;Not named.
|
|
|
|
|
(:conc-name ses-cell--))
|
|
|
|
|
symbol formula printer references properties)
|
|
|
|
|
|
|
|
|
|
(cl-defstruct (ses--locprn
|
|
|
|
|
(:constructor)
|
|
|
|
|
(:constructor ses-make-local-printer-info
|
|
|
|
|
(def &optional (compiled (ses-local-printer-compile def))
|
|
|
|
|
(number ses--numlocprn))))
|
|
|
|
|
def
|
|
|
|
|
compiled
|
|
|
|
|
number
|
|
|
|
|
local-printer-list)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defmacro ses-cell-symbol (row &optional col)
|
2020-12-19 16:14:33 +00:00
|
|
|
|
"Return symbol of the local-variable holding value of CELL or pair (ROW,COL).
|
|
|
|
|
For example, (0,0) => A1."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
|
|
|
|
`(ses-cell--symbol ,(if col `(ses-get-cell ,row ,col) row)))
|
2011-06-27 06:11:36 +00:00
|
|
|
|
(put 'ses-cell-symbol 'safe-function t)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses-cell-formula (row &optional col)
|
|
|
|
|
"From a CELL or a pair (ROW,COL), get the function that computes its value."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
|
|
|
|
`(ses-cell--formula ,(if col `(ses-get-cell ,row ,col) row)))
|
2012-07-22 21:14:12 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defmacro ses-cell-printer (row &optional col)
|
|
|
|
|
"From a CELL or a pair (ROW,COL), get the function that prints its value."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
|
|
|
|
`(ses-cell--printer ,(if col `(ses-get-cell ,row ,col) row)))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defmacro ses-cell-references (row &optional col)
|
|
|
|
|
"From a CELL or a pair (ROW,COL), get the list of symbols for cells whose
|
|
|
|
|
functions refer to its value."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
|
|
|
|
`(ses-cell--references ,(if col `(ses-get-cell ,row ,col) row)))
|
2012-07-22 21:14:12 +00:00
|
|
|
|
|
2015-04-05 17:18:19 +00:00
|
|
|
|
(defmacro ses-sym-rowcol (sym)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"From a cell-symbol SYM, gets the cons (row . col). A1 => (0 . 0).
|
|
|
|
|
Result is nil if SYM is not a symbol that names a cell."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(declare (debug t))
|
2015-04-05 17:18:19 +00:00
|
|
|
|
`(let ((rc (and (symbolp ,sym) (get ,sym 'ses-cell))))
|
|
|
|
|
(if (eq rc :ses-named)
|
2017-06-23 09:16:37 +00:00
|
|
|
|
(and ses--named-cell-hashmap (gethash ,sym ses--named-cell-hashmap))
|
2015-04-05 17:18:19 +00:00
|
|
|
|
rc)))
|
|
|
|
|
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(defun ses-cell-p (cell)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
"Return non-nil if CELL is a cell of current buffer."
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(and (vectorp cell)
|
|
|
|
|
(= (length cell) 5)
|
|
|
|
|
(eq cell (let ((rowcol (ses-sym-rowcol (ses-cell-symbol cell))))
|
|
|
|
|
(and (consp rowcol)
|
|
|
|
|
(ses-get-cell (car rowcol) (cdr rowcol)))))))
|
|
|
|
|
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(defun ses-plist-delq (plist prop)
|
2016-01-31 04:05:26 +00:00
|
|
|
|
"Return PLIST after deleting the first pair (if any) with symbol PROP.
|
|
|
|
|
This can alter PLIST."
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(cond
|
|
|
|
|
((null plist) nil)
|
|
|
|
|
((eq (car plist) prop) (cddr plist))
|
|
|
|
|
(t (let* ((plist-1 (cdr plist))
|
|
|
|
|
(plist-2 (cdr plist-1)))
|
|
|
|
|
(setcdr plist-1 (ses-plist-delq plist-2 prop))
|
|
|
|
|
plist))))
|
|
|
|
|
|
|
|
|
|
(defvar ses--ses-buffer-list nil "A list of buffers containing a SES spreadsheet.")
|
|
|
|
|
|
|
|
|
|
(defun ses--unbind-cell-name (name)
|
|
|
|
|
"Make NAME non longer a renamed cell name."
|
|
|
|
|
(remhash name ses--named-cell-hashmap)
|
|
|
|
|
(kill-local-variable name)
|
|
|
|
|
;; remove symbol property 'ses-cell from symbol NAME, unless this
|
|
|
|
|
;; symbol is also a renamed cell name in another SES buffer.
|
|
|
|
|
(let (used-elsewhere (buffer-list ses--ses-buffer-list) buf)
|
|
|
|
|
(while buffer-list
|
|
|
|
|
(setq buf (pop buffer-list))
|
|
|
|
|
(cond
|
|
|
|
|
((eq buf (current-buffer)))
|
|
|
|
|
;; This case should not happen, some SES buffer has been
|
|
|
|
|
;; killed without the ses-killbuffer-hook being called.
|
|
|
|
|
((null (buffer-live-p buf))
|
|
|
|
|
;; Silently repair ses--ses-buffer-list
|
|
|
|
|
(setq ses--ses-buffer-list (delq buf ses--ses-buffer-list)))
|
|
|
|
|
(t
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(when (gethash name ses--named-cell-hashmap)
|
|
|
|
|
(setq used-elsewhere t
|
|
|
|
|
buffer-list nil))))))
|
|
|
|
|
(unless used-elsewhere
|
|
|
|
|
(setplist name (ses-plist-delq (symbol-plist name) 'ses-cell))) ))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses--letref (vars place &rest body)
|
2019-10-16 02:44:22 +00:00
|
|
|
|
(declare (indent 2) (debug (sexp form body)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(gv-letplace (getter setter) place
|
|
|
|
|
`(cl-macrolet ((,(nth 0 vars) () ',getter)
|
2014-09-29 20:25:19 +00:00
|
|
|
|
(,(nth 1 vars) (v) (funcall ',setter v)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
,@body)))
|
|
|
|
|
|
|
|
|
|
(defmacro ses-cell-property (property-name row &optional col)
|
|
|
|
|
"Get property named PROPERTY-NAME from a CELL or a pair (ROW,COL).
|
2011-06-27 06:02:27 +00:00
|
|
|
|
|
|
|
|
|
When COL is omitted, CELL=ROW is a cell object. When COL is
|
|
|
|
|
present ROW and COL are the integer coordinates of the cell of
|
|
|
|
|
interest."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(declare (debug t))
|
2014-10-01 17:23:42 +00:00
|
|
|
|
`(alist-get ,property-name
|
|
|
|
|
(ses-cell--properties
|
|
|
|
|
,(if col `(ses-get-cell ,row ,col) row))))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses-cell-property-pop (property-name row &optional col)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
"From a CELL or a pair (ROW,COL), get and remove the property value of
|
2011-06-27 06:02:27 +00:00
|
|
|
|
the corresponding cell with name PROPERTY-NAME."
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
`(ses--letref (pget pset)
|
2014-10-01 17:23:42 +00:00
|
|
|
|
(alist-get ,property-name
|
|
|
|
|
(ses-cell--properties
|
|
|
|
|
,(if col `(ses-get-cell ,row ,col) row))
|
|
|
|
|
nil t)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(prog1 (pget) (pset nil))))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defmacro ses-cell-value (row &optional col)
|
|
|
|
|
"From a CELL or a pair (ROW,COL), get the current value for that cell."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(declare (debug t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
`(symbol-value (ses-cell-symbol ,row ,col)))
|
|
|
|
|
|
|
|
|
|
(defmacro ses-col-width (col)
|
|
|
|
|
"Return the width for column COL."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(declare (debug t))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
`(aref ses--col-widths ,col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses-col-printer (col)
|
|
|
|
|
"Return the default printer for column COL."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(declare (debug t))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
`(aref ses--col-printers ,col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(defun ses-is-cell-sym-p (sym)
|
|
|
|
|
"Check whether SYM point at a cell of this spread sheet."
|
|
|
|
|
(let ((rowcol (get sym 'ses-cell)))
|
|
|
|
|
(and rowcol
|
|
|
|
|
(if (eq rowcol :ses-named)
|
|
|
|
|
(and ses--named-cell-hashmap (gethash sym ses--named-cell-hashmap))
|
|
|
|
|
(and (< (car rowcol) ses--numrows)
|
|
|
|
|
(< (cdr rowcol) ses--numcols)
|
|
|
|
|
(eq (ses-cell-symbol (car rowcol) (cdr rowcol)) sym))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(defun ses--cell (sym value formula printer references)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Load a cell SYM from the spreadsheet file.
|
|
|
|
|
Does not recompute VALUE from FORMULA, does not reprint using
|
|
|
|
|
PRINTER, does not check REFERENCES. Safety-checking for FORMULA
|
|
|
|
|
and PRINTER are deferred until first use."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((rowcol (ses-sym-rowcol sym)))
|
|
|
|
|
(ses-formula-record formula)
|
|
|
|
|
(ses-printer-record printer)
|
2014-10-25 10:40:14 +00:00
|
|
|
|
(unless (or formula (eq value '*skip*))
|
2014-10-24 23:02:25 +00:00
|
|
|
|
(setq formula (macroexp-quote value)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (atom formula)
|
|
|
|
|
(eq safe-functions t)
|
|
|
|
|
(setq formula `(ses-safe-formula ,formula)))
|
|
|
|
|
(or (not printer)
|
|
|
|
|
(stringp printer)
|
|
|
|
|
(eq safe-functions t)
|
|
|
|
|
(setq printer `(ses-safe-printer ,printer)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-get-cell (car rowcol) (cdr rowcol))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(ses-make-cell sym formula printer references)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(set sym value))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(defun ses-local-printer-compile (printer)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Convert local printer function into faster printer definition."
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(cond
|
|
|
|
|
((functionp printer) printer)
|
|
|
|
|
((stringp printer)
|
2016-08-10 08:13:27 +00:00
|
|
|
|
`(lambda (x)
|
|
|
|
|
(if (null x) ""
|
|
|
|
|
(format ,printer x))))
|
2016-08-09 21:46:13 +00:00
|
|
|
|
((stringp (car-safe printer))
|
|
|
|
|
`(lambda (x)
|
2016-08-10 08:13:27 +00:00
|
|
|
|
(if (null x) ""
|
|
|
|
|
(setq ses-call-printer-return t)
|
|
|
|
|
(format ,(car printer) x))))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(t (error "Invalid printer %S" printer))))
|
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(defun ses--local-printer (name def)
|
|
|
|
|
"Define a local printer with name NAME and definition DEF.
|
|
|
|
|
Return the printer info."
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(or
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(and (symbolp name)
|
|
|
|
|
(ses-printer-validate def))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(error "Invalid local printer definition"))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(and (gethash name ses--local-printer-hashmap)
|
|
|
|
|
(error "Duplicate printer definition %S" name))
|
|
|
|
|
(add-to-list 'ses-read-printer-history (symbol-name name))
|
|
|
|
|
(puthash name
|
|
|
|
|
(ses-make-local-printer-info (ses-safe-printer def))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
ses--local-printer-hashmap))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defmacro ses-column-widths (widths)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Load the vector of column widths from the spreadsheet file.
|
|
|
|
|
This is a macro to prevent propagate-on-load viruses."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(or (and (vectorp widths) (= (length widths) ses--numcols))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Bad column-width vector"))
|
|
|
|
|
;;To save time later, we also calculate the total width of each line in the
|
|
|
|
|
;;print area (excluding the terminating newline)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--col-widths widths
|
2014-09-30 17:52:11 +00:00
|
|
|
|
ses--linewidth (apply #'+ -1 (mapcar #'1+ widths))
|
2005-07-04 02:27:03 +00:00
|
|
|
|
ses--blank-line (concat (make-string ses--linewidth ?\s) "\n"))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
(defmacro ses-column-printers (printers)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Load the vector of column printers from the spreadsheet file and check
|
2002-09-28 18:45:56 +00:00
|
|
|
|
them for safety. This is a macro to prevent propagate-on-load viruses."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(or (and (vectorp printers) (= (length printers) ses--numcols))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Bad column-printers vector"))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (x ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(aset printers x (ses-safe-printer (aref printers x))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--col-printers printers)
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(mapc #'ses-printer-record printers)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
(defmacro ses-default-printer (def)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Load the global default printer from the spreadsheet file and check it
|
2002-09-28 18:45:56 +00:00
|
|
|
|
for safety. This is a macro to prevent propagate-on-load viruses."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--default-printer (ses-safe-printer def))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-printer-record def)
|
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
(defmacro ses-header-row (row)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Load the header row from the spreadsheet file and check it
|
2002-09-28 18:45:56 +00:00
|
|
|
|
for safety. This is a macro to prevent propagate-on-load viruses."
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(or (and (wholenump row) (or (zerop ses--numrows) (< row ses--numrows)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Bad header-row"))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--header-row row)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
(defmacro ses-dorange (curcell &rest body)
|
2014-09-30 17:52:11 +00:00
|
|
|
|
"Execute BODY repeatedly, with the variables `row' and `col' set to each
|
|
|
|
|
cell in the range specified by CURCELL. The range is available in the
|
|
|
|
|
variables `minrow', `maxrow', `mincol', and `maxcol'."
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(declare (indent defun) (debug (form body)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((cur (make-symbol "cur"))
|
|
|
|
|
(min (make-symbol "min"))
|
|
|
|
|
(max (make-symbol "max"))
|
|
|
|
|
(r (make-symbol "r"))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(c (make-symbol "c")))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
`(let* ((,cur ,curcell)
|
|
|
|
|
(,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur)))
|
|
|
|
|
(,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur))))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(let ((minrow (car ,min))
|
|
|
|
|
(maxrow (car ,max))
|
|
|
|
|
(mincol (cdr ,min))
|
|
|
|
|
(maxcol (cdr ,max)))
|
|
|
|
|
(if (or (> minrow maxrow) (> mincol maxcol))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Empty range"))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(dotimes (,r (- maxrow minrow -1))
|
|
|
|
|
(let ((row (+ ,r minrow)))
|
|
|
|
|
(dotimes (,c (- maxcol mincol -1))
|
|
|
|
|
(let ((col (+ ,c mincol)))
|
|
|
|
|
,@body))))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Utility functions
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-vector-insert (array idx new)
|
|
|
|
|
"Create a new vector which is one larger than ARRAY and has NEW inserted
|
|
|
|
|
before element IDX."
|
|
|
|
|
(let* ((len (length array))
|
|
|
|
|
(result (make-vector (1+ len) new)))
|
|
|
|
|
(dotimes (x len)
|
|
|
|
|
(aset result
|
|
|
|
|
(if (< x idx) x (1+ x))
|
|
|
|
|
(aref array x)))
|
|
|
|
|
result))
|
|
|
|
|
|
|
|
|
|
;;Allow ARRAY to be a symbol for use in buffer-undo-list
|
|
|
|
|
(defun ses-vector-delete (array idx count)
|
|
|
|
|
"Create a new vector which is a copy of ARRAY with COUNT objects removed
|
|
|
|
|
starting at element IDX. ARRAY is either a vector or a symbol whose value
|
|
|
|
|
is a vector--if a symbol, the new vector is assigned as the symbol's value."
|
|
|
|
|
(let* ((a (if (arrayp array) array (symbol-value array)))
|
|
|
|
|
(len (- (length a) count))
|
|
|
|
|
(result (make-vector len nil)))
|
|
|
|
|
(dotimes (x len)
|
|
|
|
|
(aset result x (aref a (if (< x idx) x (+ x count)))))
|
|
|
|
|
(if (symbolp array)
|
|
|
|
|
(set array result))
|
|
|
|
|
result))
|
|
|
|
|
|
|
|
|
|
(defun ses-delete-line (count)
|
|
|
|
|
"Like `kill-line', but no kill ring."
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(forward-line count)
|
|
|
|
|
(delete-region pos (point))))
|
|
|
|
|
|
|
|
|
|
(defun ses-printer-validate (printer)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Signal an error if PRINTER is not a valid SES cell printer."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (not printer)
|
|
|
|
|
(stringp printer)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; printer is a local printer
|
|
|
|
|
(and (symbolp printer) (gethash printer ses--local-printer-hashmap))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(functionp printer)
|
|
|
|
|
(and (stringp (car-safe printer)) (not (cdr printer)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(error "Invalid printer function %S" printer))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
printer)
|
|
|
|
|
|
|
|
|
|
(defun ses-printer-record (printer)
|
|
|
|
|
"Add PRINTER to `ses-read-printer-history' if not already there, after first
|
|
|
|
|
checking that it is a valid printer function."
|
|
|
|
|
(ses-printer-validate printer)
|
|
|
|
|
;;To speed things up, we avoid calling prin1 for the very common "nil" case.
|
|
|
|
|
(if printer
|
|
|
|
|
(add-to-list 'ses-read-printer-history (prin1-to-string printer))))
|
|
|
|
|
|
|
|
|
|
(defun ses-formula-record (formula)
|
2015-11-17 23:28:50 +00:00
|
|
|
|
"If FORMULA is of the form \\='SYMBOL, add it to the list of symbolic formulas
|
2002-09-28 18:45:56 +00:00
|
|
|
|
for this spreadsheet."
|
|
|
|
|
(when (and (eq (car-safe formula) 'quote)
|
|
|
|
|
(symbolp (cadr formula)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(add-to-list 'ses--symbolic-formulas
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(list (symbol-name (cadr formula))))))
|
|
|
|
|
|
|
|
|
|
(defun ses-column-letter (col)
|
2007-10-25 20:12:26 +00:00
|
|
|
|
"Return the alphabetic name of column number COL.
|
|
|
|
|
0-25 become A-Z; 26-701 become AA-ZZ, and so on."
|
|
|
|
|
(let ((units (char-to-string (+ ?A (% col 26)))))
|
|
|
|
|
(if (< col 26)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
units
|
2007-10-25 20:12:26 +00:00
|
|
|
|
(concat (ses-column-letter (1- (/ col 26))) units))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-create-cell-symbol (row col)
|
2015-11-17 23:28:50 +00:00
|
|
|
|
"Produce a symbol that names the cell (ROW,COL). (0,0) => A1."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(intern (concat (ses-column-letter col) (number-to-string (1+ row)))))
|
|
|
|
|
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(defun ses-decode-cell-symbol (str)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Decode a symbol \"A1\" => (0,0).
|
|
|
|
|
Return nil if STR is not a canonical cell name."
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(let (case-fold-search)
|
|
|
|
|
(and (string-match "\\`\\([A-Z]+\\)\\([0-9]+\\)\\'" str)
|
|
|
|
|
(let* ((col-str (match-string-no-properties 1 str))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(col 0)
|
|
|
|
|
(col-base 1)
|
|
|
|
|
(col-idx (1- (length col-str)))
|
|
|
|
|
(row (1- (string-to-number
|
|
|
|
|
(match-string-no-properties 2 str)))))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(and (>= row 0)
|
|
|
|
|
(progn
|
|
|
|
|
(while
|
|
|
|
|
(progn
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setq col (+ col (* (- (aref col-str col-idx) ?A)
|
|
|
|
|
col-base))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
col-base (* col-base 26)
|
|
|
|
|
col-idx (1- col-idx))
|
|
|
|
|
(and (>= col-idx 0)
|
|
|
|
|
(setq col (+ col col-base)))))
|
|
|
|
|
(cons row col)))))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-create-cell-variable-range (minrow maxrow mincol maxcol)
|
|
|
|
|
"Create buffer-local variables for cells. This is undoable."
|
2005-01-31 22:47:40 +00:00
|
|
|
|
(push `(apply ses-destroy-cell-variable-range ,minrow ,maxrow ,mincol ,maxcol)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
buffer-undo-list)
|
|
|
|
|
(let (sym xrow xcol)
|
|
|
|
|
(dotimes (row (1+ (- maxrow minrow)))
|
|
|
|
|
(dotimes (col (1+ (- maxcol mincol)))
|
|
|
|
|
(setq xrow (+ row minrow)
|
|
|
|
|
xcol (+ col mincol)
|
|
|
|
|
sym (ses-create-cell-symbol xrow xcol))
|
|
|
|
|
(put sym 'ses-cell (cons xrow xcol))
|
|
|
|
|
(make-local-variable sym)))))
|
|
|
|
|
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(defun ses-create-cell-variable (sym row col)
|
|
|
|
|
"Create a buffer-local variable `SYM' for cell at position (ROW, COL).
|
|
|
|
|
|
|
|
|
|
SYM is the symbol for that variable, ROW and COL are integers for
|
|
|
|
|
row and column of the cell, with numbering starting from 0.
|
|
|
|
|
|
|
|
|
|
Return nil in case of failure."
|
|
|
|
|
(unless (local-variable-p sym)
|
|
|
|
|
(make-local-variable sym)
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(if (let (case-fold-search) (string-match-p "\\`[A-Z]+[0-9]+\\'" (symbol-name sym)))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(put sym 'ses-cell (cons row col))
|
|
|
|
|
(put sym 'ses-cell :ses-named)
|
|
|
|
|
(setq ses--named-cell-hashmap (or ses--named-cell-hashmap (make-hash-table :test 'eq)))
|
|
|
|
|
(puthash sym (cons row col) ses--named-cell-hashmap))))
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
|
2011-06-27 08:14:10 +00:00
|
|
|
|
;; We do not delete the ses-cell properties for the cell-variables, in
|
|
|
|
|
;; case a formula that refers to this cell is in the kill-ring and is
|
|
|
|
|
;; later pasted back in.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-destroy-cell-variable-range (minrow maxrow mincol maxcol)
|
|
|
|
|
"Destroy buffer-local variables for cells. This is undoable."
|
|
|
|
|
(let (sym)
|
|
|
|
|
(dotimes (row (1+ (- maxrow minrow)))
|
|
|
|
|
(dotimes (col (1+ (- maxcol mincol)))
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(let ((xrow (+ row minrow)) (xcol (+ col mincol)))
|
|
|
|
|
(setq sym (if (and (< xrow ses--numrows) (< xcol ses--numcols))
|
|
|
|
|
(ses-cell-symbol xrow xcol)
|
|
|
|
|
(ses-create-cell-symbol xrow xcol))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (boundp sym)
|
2005-01-31 22:47:40 +00:00
|
|
|
|
(push `(apply ses-set-with-undo ,sym ,(symbol-value sym))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
buffer-undo-list))
|
|
|
|
|
(kill-local-variable sym))))
|
2005-01-31 22:47:40 +00:00
|
|
|
|
(push `(apply ses-create-cell-variable-range ,minrow ,maxrow ,mincol ,maxcol)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
buffer-undo-list))
|
|
|
|
|
|
|
|
|
|
(defun ses-reset-header-string ()
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Flag the header string for update.
|
|
|
|
|
Upon undo, the header string will be updated again."
|
2005-01-31 22:47:40 +00:00
|
|
|
|
(push '(apply ses-reset-header-string) buffer-undo-list)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--header-hscroll -1))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
;;Split this code off into a function to avoid coverage-testing difficulties
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(defmacro ses--time-check (format &rest args)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"If `ses-start-time' is more than a second ago, call `message' with FORMAT
|
2014-09-30 17:52:11 +00:00
|
|
|
|
and ARGS and reset `ses-start-time' to the current time."
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
|
`(when (time-less-p 1 (time-since ses-start-time))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(message ,format ,@args)
|
|
|
|
|
(setq ses-start-time (float-time))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; The cells
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(defmacro ses-set-cell (row col field val)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Install VAL as the contents for field FIELD (named by a quoted symbol) of
|
|
|
|
|
cell (ROW,COL). This is undoable. The cell's data will be updated through
|
|
|
|
|
`post-command-hook'."
|
2021-03-11 18:11:40 +00:00
|
|
|
|
(macroexp-let2 nil row row
|
|
|
|
|
(macroexp-let2 nil col col
|
|
|
|
|
(macroexp-let2 nil val val
|
|
|
|
|
`(let* ((cell (ses-get-cell ,row ,col))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(change
|
2014-09-30 17:52:11 +00:00
|
|
|
|
,(let ((field (progn (cl-assert (eq (car field) 'quote))
|
|
|
|
|
(cadr field))))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(if (eq field 'value)
|
2021-03-11 18:11:40 +00:00
|
|
|
|
`(ses-set-with-undo (ses-cell-symbol cell) ,val)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
;; (let* ((slots (get 'ses-cell 'cl-struct-slots))
|
|
|
|
|
;; (slot (or (assq field slots)
|
|
|
|
|
;; (error "Unknown field %S" field)))
|
|
|
|
|
;; (idx (- (length slots)
|
|
|
|
|
;; (length (memq slot slots)))))
|
2021-03-11 18:11:40 +00:00
|
|
|
|
;; `(ses-aset-with-undo cell ,idx ,val))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let ((getter (intern-soft (format "ses-cell--%s" field))))
|
|
|
|
|
`(ses-setter-with-undo
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(cons #',getter
|
|
|
|
|
(lambda (newval cell)
|
|
|
|
|
(setf (,getter cell) newval))))
|
2021-03-11 18:11:40 +00:00
|
|
|
|
,val cell))))))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(if change
|
2021-03-11 18:11:40 +00:00
|
|
|
|
(add-to-list 'ses--deferred-write (cons ,row ,col)))
|
|
|
|
|
nil))))) ; Make coverage-tester happy.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-cell-set-formula (row col formula)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Store a new formula for (ROW . COL) and enqueue the cell for
|
2002-09-28 18:45:56 +00:00
|
|
|
|
recalculation via `post-command-hook'. Updates the reference lists for the
|
|
|
|
|
cells that this cell refers to. Does not update cell value or reprint the
|
|
|
|
|
cell. To avoid inconsistencies, this function is not interruptible, which
|
|
|
|
|
means Emacs will crash if FORMULA contains a circular list."
|
|
|
|
|
(let* ((cell (ses-get-cell row col))
|
|
|
|
|
(old (ses-cell-formula cell)))
|
|
|
|
|
(let ((sym (ses-cell-symbol cell))
|
|
|
|
|
(oldref (ses-formula-references old))
|
|
|
|
|
(newref (ses-formula-references formula))
|
|
|
|
|
(inhibit-quit t)
|
2017-06-23 09:16:37 +00:00
|
|
|
|
not-a-cell-ref-list
|
2002-09-28 18:45:56 +00:00
|
|
|
|
x xrow xcol)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew sym ses--deferred-recalc)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Delete old references from this cell. Skip the ones that are also
|
|
|
|
|
;;in the new list.
|
|
|
|
|
(dolist (ref oldref)
|
|
|
|
|
(unless (memq ref newref)
|
2017-06-23 09:16:37 +00:00
|
|
|
|
;; because we do not cancel edit when the user provides a
|
|
|
|
|
;; false reference in it, then we need to check that ref
|
|
|
|
|
;; points to a cell that is within the spreadsheet.
|
|
|
|
|
(setq x (ses-sym-rowcol ref))
|
|
|
|
|
(and x
|
|
|
|
|
(< (setq xrow (car x)) ses--numrows)
|
|
|
|
|
(< (setq xcol (cdr x)) ses--numcols)
|
|
|
|
|
(ses-set-cell xrow xcol 'references
|
|
|
|
|
(delq sym (ses-cell-references xrow xcol))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Add new ones. Skip ones left over from old list
|
|
|
|
|
(dolist (ref newref)
|
2017-06-23 09:16:37 +00:00
|
|
|
|
(setq x (ses-sym-rowcol ref))
|
|
|
|
|
;;Do not trust the user, the reference may be outside the spreadsheet
|
|
|
|
|
(if (and
|
|
|
|
|
x
|
|
|
|
|
(< (setq xrow (car x)) ses--numrows)
|
|
|
|
|
(< (setq xcol (cdr x)) ses--numcols))
|
|
|
|
|
(progn
|
|
|
|
|
(setq x (ses-cell-references xrow xcol))
|
|
|
|
|
(or (memq sym x)
|
|
|
|
|
(ses-set-cell xrow xcol 'references (cons sym x))))
|
|
|
|
|
(cl-pushnew ref not-a-cell-ref-list)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-formula-record formula)
|
2017-06-23 09:16:37 +00:00
|
|
|
|
(ses-set-cell row col 'formula formula)
|
|
|
|
|
(and not-a-cell-ref-list
|
|
|
|
|
(error "Found in formula cells not in spreadsheet: %S" not-a-cell-ref-list)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2011-06-27 06:11:36 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-repair-cell-reference-all ()
|
|
|
|
|
"Repair cell reference and warn if there was some reference corruption."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(let (errors)
|
|
|
|
|
;; Step 1, reset :ses-repair-reference cell property in the whole sheet.
|
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(let ((references (ses-cell-property-pop :ses-repair-reference
|
|
|
|
|
row col)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(when references
|
|
|
|
|
(push (list (ses-cell-symbol row col)
|
|
|
|
|
:corrupt-property
|
|
|
|
|
references)
|
|
|
|
|
errors)))))
|
2011-06-27 06:11:36 +00:00
|
|
|
|
|
|
|
|
|
;; Step 2, build new.
|
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(let* ((cell (ses-get-cell row col))
|
|
|
|
|
(sym (ses-cell-symbol cell))
|
|
|
|
|
(formula (ses-cell-formula cell))
|
|
|
|
|
(new-ref (ses-formula-references formula)))
|
|
|
|
|
(dolist (ref new-ref)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let ((rowcol (ses-sym-rowcol ref)))
|
|
|
|
|
(cl-pushnew sym (ses-cell-property :ses-repair-reference
|
|
|
|
|
(car rowcol)
|
|
|
|
|
(cdr rowcol))))))))
|
2011-06-27 06:11:36 +00:00
|
|
|
|
|
|
|
|
|
;; Step 3, overwrite with check.
|
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(let* ((cell (ses-get-cell row col))
|
|
|
|
|
(irrelevant (ses-cell-references cell))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(new-ref (ses-cell-property-pop :ses-repair-reference cell))
|
2011-06-27 06:11:36 +00:00
|
|
|
|
missing)
|
|
|
|
|
(dolist (ref new-ref)
|
|
|
|
|
(if (memq ref irrelevant)
|
|
|
|
|
(setq irrelevant (delq ref irrelevant))
|
|
|
|
|
(push ref missing)))
|
|
|
|
|
(ses-set-cell row col 'references new-ref)
|
|
|
|
|
(when (or missing irrelevant)
|
|
|
|
|
(push `( ,(ses-cell-symbol cell)
|
|
|
|
|
,@(and missing (list :missing missing))
|
|
|
|
|
,@(and irrelevant (list :irrelevant irrelevant)))
|
|
|
|
|
errors)))))
|
|
|
|
|
(if errors
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(warn "----------------------------------------------------------------
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
Some references were corrupted.
|
2011-06-27 06:11:36 +00:00
|
|
|
|
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
The following is a list where each element ELT is such
|
2011-06-27 06:11:36 +00:00
|
|
|
|
that (car ELT) is the reference of cell CELL with corruption,
|
|
|
|
|
and (cdr ELT) is a property list where
|
|
|
|
|
|
|
|
|
|
* property `:corrupt-property' means that
|
|
|
|
|
property `:ses-repair-reference' of cell CELL was initially non
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
|
|
* property `:missing' is a list of missing references
|
|
|
|
|
|
|
|
|
|
* property `:irrelevant' is a list of non needed references
|
|
|
|
|
|
|
|
|
|
%S" errors)
|
|
|
|
|
(message "No reference corruption found"))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-calculate-cell (row col force)
|
|
|
|
|
"Calculate and print the value for cell (ROW,COL) using the cell's formula
|
|
|
|
|
function and print functions, if any. Result is nil for normal operation, or
|
|
|
|
|
the error signal if the formula or print function failed. The old value is
|
|
|
|
|
left unchanged if it was *skip* and the new value is nil.
|
|
|
|
|
Any cells that depend on this cell are queued for update after the end of
|
|
|
|
|
processing for the current keystroke, unless the new value is the same as
|
|
|
|
|
the old and FORCE is nil."
|
|
|
|
|
(let ((cell (ses-get-cell row col))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
cycle-error formula-error printer-error)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(let ((oldval (ses-cell-value cell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(formula (ses-cell-formula cell))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
newval
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
this-cell-Dijkstra-attempt+1)
|
2007-09-23 01:08:25 +00:00
|
|
|
|
(when (eq (car-safe formula) 'ses-safe-formula)
|
|
|
|
|
(setq formula (ses-safe-formula (cadr formula)))
|
|
|
|
|
(ses-set-cell row col 'formula formula))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(condition-case sig
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq newval (eval formula t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;; Variable `sig' can't be nil.
|
|
|
|
|
(nconc sig (list (ses-cell-symbol cell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq formula-error sig
|
|
|
|
|
newval '*error*)))
|
|
|
|
|
(if (and (not newval) (eq oldval '*skip*))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Don't lose the *skip* --- previous field spans this one.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq newval '*skip*))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(catch 'cycle
|
|
|
|
|
(when (or force (not (eq newval oldval)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew (cons row col) ses--deferred-write :test #'equal) ; In case force=t.
|
|
|
|
|
(ses--letref (pget pset)
|
|
|
|
|
(ses-cell-property :ses-Dijkstra-attempt cell)
|
|
|
|
|
(let ((this-cell-Dijkstra-attempt (pget)))
|
|
|
|
|
(if (null this-cell-Dijkstra-attempt)
|
|
|
|
|
(pset
|
|
|
|
|
(setq this-cell-Dijkstra-attempt
|
|
|
|
|
(cons ses--Dijkstra-attempt-nb 0)))
|
|
|
|
|
(unless (= ses--Dijkstra-attempt-nb
|
|
|
|
|
(car this-cell-Dijkstra-attempt))
|
|
|
|
|
(setcar this-cell-Dijkstra-attempt ses--Dijkstra-attempt-nb)
|
|
|
|
|
(setcdr this-cell-Dijkstra-attempt 0)))
|
|
|
|
|
(setq this-cell-Dijkstra-attempt+1
|
|
|
|
|
(1+ (cdr this-cell-Dijkstra-attempt)))))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-set-cell row col 'value newval)
|
|
|
|
|
(dolist (ref (ses-cell-references cell))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew ref ses--deferred-recalc)
|
|
|
|
|
(ses--letref (pget pset)
|
|
|
|
|
(let ((ref-rowcol (ses-sym-rowcol ref)))
|
|
|
|
|
(ses-cell-property
|
|
|
|
|
:ses-Dijkstra-attempt
|
|
|
|
|
(car ref-rowcol) (cdr ref-rowcol)))
|
|
|
|
|
(let ((ref-cell-Dijkstra-attempt (pget)))
|
|
|
|
|
|
|
|
|
|
(if (null ref-cell-Dijkstra-attempt)
|
|
|
|
|
(pset
|
|
|
|
|
(setq ref-cell-Dijkstra-attempt
|
|
|
|
|
(cons ses--Dijkstra-attempt-nb
|
|
|
|
|
this-cell-Dijkstra-attempt+1)))
|
|
|
|
|
(if (= (car ref-cell-Dijkstra-attempt) ses--Dijkstra-attempt-nb)
|
|
|
|
|
(setcdr ref-cell-Dijkstra-attempt
|
|
|
|
|
(max (cdr ref-cell-Dijkstra-attempt)
|
|
|
|
|
this-cell-Dijkstra-attempt+1))
|
|
|
|
|
(setcar ref-cell-Dijkstra-attempt ses--Dijkstra-attempt-nb)
|
|
|
|
|
(setcdr ref-cell-Dijkstra-attempt
|
|
|
|
|
this-cell-Dijkstra-attempt+1)))))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
|
|
|
|
|
(when (> this-cell-Dijkstra-attempt+1 ses--Dijkstra-weight-bound)
|
|
|
|
|
;; Update print of this cell.
|
|
|
|
|
(throw 'cycle (setq formula-error
|
|
|
|
|
`(error ,(format "Found cycle on cells %S"
|
|
|
|
|
(ses-cell-symbol cell)))
|
|
|
|
|
cycle-error formula-error)))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq printer-error (ses-print-cell row col))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(or
|
|
|
|
|
(and cycle-error
|
|
|
|
|
(error (error-message-string cycle-error)))
|
|
|
|
|
formula-error printer-error)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-clear-cell (row col)
|
|
|
|
|
"Delete formula and printer for cell (ROW,COL)."
|
|
|
|
|
(ses-set-cell row col 'printer nil)
|
|
|
|
|
(ses-cell-set-formula row col nil))
|
|
|
|
|
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(defcustom ses-self-reference-early-detection nil
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Non-nil if cycle detection is early for cells that refer to themselves."
|
Add missing :version tags to new defgroups and defcustoms
* window.el (window-sides-slots):
* tool-bar.el (tool-bar-position):
* term/xterm.el (xterm-extra-capabilities):
* ses.el (ses-self-reference-early-detection):
* progmodes/verilog-mode.el (verilog-auto-declare-nettype)
(verilog-auto-wire-type)
(verilog-auto-delete-trailing-whitespace)
(verilog-auto-reset-blocking-in-non, verilog-auto-inst-sort)
(verilog-auto-tieoff-declaration):
* progmodes/sql.el (sql-login-hook, sql-ansi-statement-starters)
(sql-oracle-statement-starters, sql-oracle-scan-on):
* progmodes/prolog.el (prolog-align-comments-flag)
(prolog-indent-mline-comments-flag, prolog-object-end-to-0-flag)
(prolog-left-indent-regexp, prolog-paren-indent-p)
(prolog-paren-indent, prolog-parse-mode, prolog-keywords)
(prolog-types, prolog-mode-specificators)
(prolog-determinism-specificators, prolog-directives)
(prolog-electric-newline-flag, prolog-hungry-delete-key-flag)
(prolog-electric-dot-flag)
(prolog-electric-dot-full-predicate-template)
(prolog-electric-underscore-flag, prolog-electric-tab-flag)
(prolog-electric-if-then-else-flag, prolog-electric-colon-flag)
(prolog-electric-dash-flag, prolog-old-sicstus-keys-flag)
(prolog-program-switches, prolog-prompt-regexp)
(prolog-debug-on-string, prolog-debug-off-string)
(prolog-trace-on-string, prolog-trace-off-string)
(prolog-zip-on-string, prolog-zip-off-string)
(prolog-use-standard-consult-compile-method-flag)
(prolog-use-prolog-tokenizer-flag, prolog-imenu-flag)
(prolog-imenu-max-lines, prolog-info-predicate-index)
(prolog-underscore-wordchar-flag, prolog-use-sicstus-sd)
(prolog-char-quote-workaround):
* progmodes/cc-vars.el (c-defun-tactic):
* net/tramp.el (tramp-encoding-command-interactive)
(tramp-local-end-of-line):
* net/soap-client.el (soap-client):
* net/netrc.el (netrc-file):
* net/gnutls.el (gnutls):
* minibuffer.el (completion-category-overrides)
(completion-cycle-threshold)
(completion-pcm-complete-word-inserts-delimiters):
* man.el (Man-name-local-regexp):
* mail/feedmail.el (feedmail-display-full-frame):
* international/characters.el (glyphless-char-display-control):
* eshell/em-ls.el (eshell-ls-date-format):
* emacs-lisp/cl-indent.el (lisp-lambda-list-keyword-alignment)
(lisp-lambda-list-keyword-parameter-indentation)
(lisp-lambda-list-keyword-parameter-alignment):
* doc-view.el (doc-view-image-width, doc-view-unoconv-program):
* dired-x.el (dired-omit-verbose):
* cus-theme.el (custom-theme-allow-multiple-selections):
* calc/calc.el (calc-highlight-selections-with-faces)
(calc-lu-field-reference, calc-lu-power-reference)
(calc-note-threshold):
* battery.el (battery-mode-line-limit):
* arc-mode.el (archive-7z-extract, archive-7z-expunge)
(archive-7z-update):
* allout.el (allout-prefixed-keybindings)
(allout-unprefixed-keybindings)
(allout-inhibit-auto-fill-on-headline)
(allout-flattened-numbering-abbreviation):
* allout-widgets.el (allout-widgets-auto-activation)
(allout-widgets-icons-dark-subdir)
(allout-widgets-icons-light-subdir, allout-widgets-icon-types)
(allout-widgets-theme-dark-background)
(allout-widgets-theme-light-background)
(allout-widgets-item-image-properties-emacs)
(allout-widgets-item-image-properties-xemacs)
(allout-widgets-run-unit-tests-on-load)
(allout-widgets-time-decoration-activity)
(allout-widgets-hook-error-post-time)
(allout-widgets-track-decoration):
* gnus/sieve-manage.el (sieve-manage-default-stream):
* gnus/shr.el (shr):
* gnus/nnir.el (nnir-ignored-newsgroups, nnir-summary-line-format)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-notmuch-program)
(nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix)
(nnir-method-default-engines):
* gnus/message.el (message-cite-reply-position):
* gnus/gssapi.el (gssapi-program):
* gnus/gravatar.el (gravatar):
* gnus/gnus-sum.el (gnus-refer-thread-use-nnir):
* gnus/gnus-registry.el (gnus-registry-unfollowed-addresses)
(gnus-registry-max-pruned-entries):
* gnus/gnus-picon.el (gnus-picon-inhibit-top-level-domains):
* gnus/gnus-int.el (gnus-after-set-mark-hook)
(gnus-before-update-mark-hook):
* gnus/gnus-async.el (gnus-async-post-fetch-function):
* gnus/auth-source.el (auth-source-cache-expiry):
Add missing :version tags to new defcustoms and defgroups.
2012-02-11 22:13:29 +00:00
|
|
|
|
:version "24.1"
|
2022-04-06 18:42:33 +00:00
|
|
|
|
:type 'boolean)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-update-cells (list &optional force)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Recalculate cells in LIST, checking for dependency loops.
|
|
|
|
|
Print progress messages every second. Dependent cells are not
|
|
|
|
|
recalculated if the cell's value is unchanged and FORCE is nil."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((ses--deferred-recalc list)
|
|
|
|
|
(nextlist list)
|
|
|
|
|
(pos (point))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
curlist prevlist this-sym this-rowcol formula)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(with-temp-message " "
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(while ses--deferred-recalc
|
|
|
|
|
;; In each loop, recalculate cells that refer only to other cells that
|
|
|
|
|
;; have already been recalculated or aren't in the recalculation region.
|
|
|
|
|
;; Repeat until all cells have been processed or until the set of cells
|
|
|
|
|
;; being worked on stops changing.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if prevlist
|
|
|
|
|
(message "Recalculating... (%d cells left)"
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(length ses--deferred-recalc)))
|
|
|
|
|
(setq curlist ses--deferred-recalc
|
|
|
|
|
ses--deferred-recalc nil
|
|
|
|
|
prevlist nextlist)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(while curlist
|
2011-06-27 06:02:27 +00:00
|
|
|
|
;; this-sym has to be popped from curlist *BEFORE* the check, and not
|
|
|
|
|
;; after because of the case of cells referring to themselves.
|
|
|
|
|
(setq this-sym (pop curlist)
|
|
|
|
|
this-rowcol (ses-sym-rowcol this-sym)
|
|
|
|
|
formula (ses-cell-formula (car this-rowcol)
|
|
|
|
|
(cdr this-rowcol)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (catch 'ref
|
|
|
|
|
(dolist (ref (ses-formula-references formula))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(if (and ses-self-reference-early-detection (eq ref this-sym))
|
|
|
|
|
(error "Cycle found: cell %S is self-referring" this-sym)
|
|
|
|
|
(when (or (memq ref curlist)
|
|
|
|
|
(memq ref ses--deferred-recalc))
|
|
|
|
|
;; This cell refers to another that isn't done yet
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew this-sym ses--deferred-recalc :test #'equal)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(throw 'ref t)))))
|
|
|
|
|
;; ses-update-cells is called from post-command-hook, so
|
|
|
|
|
;; inhibit-quit is implicitly bound to t.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(when quit-flag
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Abort the recalculation. User will probably undo now.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Quit"))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-calculate-cell (car this-rowcol) (cdr this-rowcol) force)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dolist (ref ses--deferred-recalc)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew ref nextlist :test #'equal)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when ses--deferred-recalc
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Just couldn't finish these.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dolist (x ses--deferred-recalc)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(let ((this-rowcol (ses-sym-rowcol x)))
|
|
|
|
|
(ses-set-cell (car this-rowcol) (cdr this-rowcol) 'value '*error*)
|
|
|
|
|
(1value (ses-print-cell (car this-rowcol) (cdr this-rowcol)))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(error "Circular references: %s" ses--deferred-recalc))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(message " "))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Can't use save-excursion here: if the cell under point is updated,
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
;; save-excursion's marker will move past the cell.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(goto-char pos)))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; The print area
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(defun ses-in-print-area ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Return t if point is in print area of spreadsheet."
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(<= (point) ses--data-marker))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We turn off point-motion-hooks and explicitly position the cursor, in case
|
|
|
|
|
;; the intangible properties have gotten screwed up (e.g., when ses-goto-print
|
|
|
|
|
;; is called during a recursive ses-print-cell).
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-goto-print (row col)
|
|
|
|
|
"Move point to print area for cell (ROW,COL)."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let ((n 0))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(forward-line row)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Calculate column position.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dotimes (c col)
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(setq n (+ n (ses-col-width c) 1)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Move to the position.
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(and (> n (move-to-column n))
|
|
|
|
|
(eolp)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Move point to the bol of next line (for TAB at the last cell).
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(forward-char))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(defun ses--cell-at-pos (pos &optional object)
|
|
|
|
|
(or (get-text-property pos 'cursor-intangible object)
|
|
|
|
|
;; (when (> pos (if object 0 (point-min)))
|
|
|
|
|
;; (get-text-property (1- pos) 'cursor-intangible object))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(defun ses--curcell (&optional pos)
|
|
|
|
|
"Return the current cell symbol, or a cons (BEG,END) for a
|
2002-09-28 18:45:56 +00:00
|
|
|
|
region, or nil if cursor is not at a cell."
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(unless pos (setq pos (point)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (or (not mark-active)
|
|
|
|
|
deactivate-mark
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(= pos (mark t)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Single cell.
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(ses--cell-at-pos pos)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Range.
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let* ((re (max pos (mark t)))
|
|
|
|
|
(bcell (ses--cell-at-pos (min pos (mark t))))
|
|
|
|
|
(ecell (ses--cell-at-pos (1- re))))
|
|
|
|
|
(when (= re ses--data-marker)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Correct for overflow.
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(setq ecell (ses--cell-at-pos (- (region-end) 2))))
|
|
|
|
|
(if (and bcell ecell)
|
|
|
|
|
(cons bcell ecell)
|
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
|
|
(defun ses-set-curcell ()
|
|
|
|
|
"Set `ses--curcell' to the current cell symbol, or a cons (BEG,END) for a
|
|
|
|
|
region, or nil if cursor is not at a cell."
|
|
|
|
|
(setq ses--curcell (ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defun ses-check-curcell (&rest args)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Signal an error if `ses--curcell' is inappropriate.
|
2015-11-17 23:28:50 +00:00
|
|
|
|
The end marker is appropriate if some argument is `end'.
|
|
|
|
|
A range is appropriate if some argument is `range'.
|
|
|
|
|
A single cell is appropriate unless some argument is `needrange'."
|
2016-01-02 15:59:03 +00:00
|
|
|
|
(ses-set-curcell); fix bug#21054
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(cond
|
2004-02-14 23:56:51 +00:00
|
|
|
|
((not ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (memq 'end args)
|
|
|
|
|
(error "Not at cell")))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
((consp ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (memq 'range args)
|
|
|
|
|
(memq 'needrange args)
|
|
|
|
|
(error "Can't use a range")))
|
|
|
|
|
((memq 'needrange args)
|
|
|
|
|
(error "Need a range"))))
|
|
|
|
|
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(defvar ses--row)
|
|
|
|
|
(defvar ses--col)
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-print-cell (row col)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Format and print the value of cell (ROW,COL) to the print area.
|
|
|
|
|
Use the cell's printer function. If the cell's new print form is too wide,
|
|
|
|
|
it will spill over into the following cell, but will not run off the end of the
|
|
|
|
|
row or overwrite the next non-nil field. Result is nil for normal operation,
|
|
|
|
|
or the error signal if the printer function failed and the cell was formatted
|
2002-09-28 18:45:56 +00:00
|
|
|
|
with \"%s\". If the cell's value is *skip*, nothing is printed because the
|
|
|
|
|
preceding cell has spilled over."
|
|
|
|
|
(catch 'ses-print-cell
|
|
|
|
|
(let* ((cell (ses-get-cell row col))
|
|
|
|
|
(value (ses-cell-value cell))
|
|
|
|
|
(printer (ses-cell-printer cell))
|
|
|
|
|
(maxcol (1+ col))
|
|
|
|
|
text sig startpos x)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Create the string to print.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(cond
|
|
|
|
|
((eq value '*skip*)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Don't print anything.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(throw 'ses-print-cell nil))
|
|
|
|
|
((eq value '*error*)
|
|
|
|
|
(setq text (make-string (ses-col-width col) ?#)))
|
|
|
|
|
(t
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Deferred safety-check on printer.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (eq (car-safe printer) 'ses-safe-printer)
|
|
|
|
|
(ses-set-cell row col 'printer
|
|
|
|
|
(setq printer (ses-safe-printer (cadr printer)))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Print the value.
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq text
|
|
|
|
|
(let ((ses--row row)
|
|
|
|
|
(ses--col col))
|
|
|
|
|
(ses-call-printer (or printer
|
|
|
|
|
(ses-col-printer col)
|
|
|
|
|
ses--default-printer)
|
|
|
|
|
value)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (consp ses-call-printer-return)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Printer returned an error.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq sig ses-call-printer-return))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Adjust print width to match column width.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((width (ses-col-width col))
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(len (string-width text)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(cond
|
|
|
|
|
((< len width)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Fill field to length with spaces.
|
2005-07-04 02:27:03 +00:00
|
|
|
|
(setq len (make-string (- width len) ?\s)
|
2017-10-05 13:49:34 +00:00
|
|
|
|
text (if (eq ses-call-printer-return t)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(concat text len)
|
|
|
|
|
(concat len text))))
|
|
|
|
|
((> len width)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Spill over into following cells, if possible.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((maxwidth width))
|
|
|
|
|
(while (and (> len maxwidth)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(< maxcol ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (not (setq x (ses-cell-value row maxcol)))
|
|
|
|
|
(eq x '*skip*)))
|
|
|
|
|
(unless x
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Set this cell to '*skip* so it won't overwrite our spillover.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row maxcol 'value '*skip*))
|
|
|
|
|
(setq maxwidth (+ maxwidth (ses-col-width maxcol) 1)
|
|
|
|
|
maxcol (1+ maxcol)))
|
|
|
|
|
(if (<= len maxwidth)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Fill to complete width of all the fields spanned.
|
2005-07-04 02:27:03 +00:00
|
|
|
|
(setq text (concat text (make-string (- maxwidth len) ?\s)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Not enough room to end of line or next non-nil field. Truncate
|
|
|
|
|
;; if string or decimal; otherwise fill with error indicator.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq sig `(error "Too wide" ,text))
|
2004-01-30 08:02:57 +00:00
|
|
|
|
(cond
|
|
|
|
|
((stringp value)
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(setq text (truncate-string-to-width text maxwidth 0 ?\s)))
|
2004-01-30 08:02:57 +00:00
|
|
|
|
((and (numberp value)
|
|
|
|
|
(string-match "\\.[0-9]+" text)
|
|
|
|
|
(>= 0 (setq width
|
|
|
|
|
(- len maxwidth
|
|
|
|
|
(- (match-end 0) (match-beginning 0))))))
|
|
|
|
|
;; Turn 6.6666666666e+49 into 6.66e+49. Rounding is too hard!
|
|
|
|
|
(setq text (concat (substring text
|
|
|
|
|
0
|
|
|
|
|
(- (match-beginning 0) width))
|
|
|
|
|
(substring text (match-end 0)))))
|
|
|
|
|
(t
|
|
|
|
|
(setq text (make-string maxwidth ?#)))))))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Substitute question marks for tabs and newlines. Newlines are used as
|
|
|
|
|
;; row-separators; tabs could confuse the reimport logic.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq text (replace-regexp-in-string "[\t\n]" "?" text))
|
|
|
|
|
(ses-goto-print row col)
|
|
|
|
|
(setq startpos (point))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Install the printed result. This is not interruptible.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
|
(inhibit-quit t))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(delete-region (point) (progn
|
|
|
|
|
(move-to-column (+ (current-column)
|
|
|
|
|
(string-width text)))
|
|
|
|
|
(1+ (point))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We use concat instead of inserting separate strings in order to
|
|
|
|
|
;; reduce the number of cells in the undo list.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq x (concat text (if (< maxcol ses--numcols) " " "\n")))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We use set-text-properties to prevent a wacky print function from
|
|
|
|
|
;; inserting rogue properties, and to ensure that the keymap property is
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
;; inherited (is it a bug that only unpropertized strings actually
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; inherit from surrounding text?)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(set-text-properties 0 (length x) nil x)
|
|
|
|
|
(insert-and-inherit x)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(put-text-property startpos (point) 'cursor-intangible
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-cell-symbol cell))
|
|
|
|
|
(when (and (zerop row) (zerop col))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Reconstruct special beginning-of-buffer attributes.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(put-text-property (point-min) (point) 'keymap 'ses-mode-print-map)
|
|
|
|
|
(put-text-property (point-min) (point) 'read-only 'ses)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(put-text-property (point-min) (1+ (point-min))
|
|
|
|
|
;; `cursor-intangible' shouldn't be sticky at BOB.
|
|
|
|
|
'front-sticky '(read-only keymap))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (= row (1- ses--header-row))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; This line is part of the header --- force recalc.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; If this cell (or a preceding one on the line) previously spilled over
|
|
|
|
|
;; and has gotten shorter, redraw following cells on line recursively.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when (and (< maxcol ses--numcols)
|
|
|
|
|
(eq (ses-cell-value row maxcol) '*skip*))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row maxcol 'value nil)
|
|
|
|
|
(ses-print-cell row maxcol))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Return to start of cell.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(goto-char startpos)
|
|
|
|
|
sig)))
|
|
|
|
|
|
|
|
|
|
(defun ses-call-printer (printer &optional value)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Invoke PRINTER (a string or parenthesized string or function-symbol or
|
2007-06-06 21:57:34 +00:00
|
|
|
|
lambda of one argument) on VALUE. Result is the printed cell as a string.
|
|
|
|
|
The variable `ses-call-printer-return' is set to t if the printer used
|
|
|
|
|
parenthesis to request left-justification, or the error-signal if the
|
2005-06-21 13:39:59 +00:00
|
|
|
|
printer signaled one (and \"%s\" is used as the default printer), else nil."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq ses-call-printer-return nil)
|
|
|
|
|
(condition-case signal
|
|
|
|
|
(cond
|
|
|
|
|
((stringp printer)
|
2011-06-27 08:14:10 +00:00
|
|
|
|
(if value
|
|
|
|
|
(format printer value)
|
|
|
|
|
""))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
((stringp (car-safe printer))
|
|
|
|
|
(setq ses-call-printer-return t)
|
2011-06-27 08:14:10 +00:00
|
|
|
|
(if value
|
|
|
|
|
(format (car printer) value)
|
|
|
|
|
""))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(t
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq value
|
|
|
|
|
(funcall
|
|
|
|
|
(or (and (symbolp printer)
|
|
|
|
|
(let ((locprn (gethash printer
|
|
|
|
|
ses--local-printer-hashmap)))
|
|
|
|
|
(and locprn
|
|
|
|
|
(ses--locprn-compiled locprn))))
|
|
|
|
|
printer)
|
2015-12-30 11:37:54 +00:00
|
|
|
|
value))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (stringp value)
|
|
|
|
|
value
|
|
|
|
|
(or (stringp (car-safe value))
|
|
|
|
|
(error "Printer should return \"string\" or (\"string\")"))
|
|
|
|
|
(setq ses-call-printer-return t)
|
|
|
|
|
(car value))))
|
|
|
|
|
(error
|
|
|
|
|
(setq ses-call-printer-return signal)
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-prin1 value))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-adjust-print-width (col change)
|
|
|
|
|
"Insert CHANGE spaces in front of column COL, or at end of line if
|
|
|
|
|
COL=NUMCOLS. Deletes characters if CHANGE < 0. Caller should bind
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
`inhibit-quit' to t."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((inhibit-read-only t)
|
2005-07-04 02:27:03 +00:00
|
|
|
|
(blank (if (> change 0) (make-string change ?\s)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(at-end (= col ses--numcols)))
|
|
|
|
|
(ses-set-with-undo 'ses--linewidth (+ ses--linewidth change))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; ses-set-with-undo always returns t for strings.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(1value (ses-set-with-undo 'ses--blank-line
|
2005-07-04 02:27:03 +00:00
|
|
|
|
(concat (make-string ses--linewidth ?\s) "\n")))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (row ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-goto-print row col)
|
|
|
|
|
(when at-end
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insert new columns before newline.
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(backward-char 1))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if blank
|
|
|
|
|
(insert blank)
|
|
|
|
|
(delete-char (- change))))))
|
|
|
|
|
|
|
|
|
|
(defun ses-print-cell-new-width (row col)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Same as `ses-print-cell', except if the cell's value is *skip*,
|
|
|
|
|
the preceding nonskipped cell is reprinted. This function is used
|
|
|
|
|
when the width of cell (ROW,COL) has changed."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (not (eq (ses-cell-value row col) '*skip*))
|
|
|
|
|
(ses-print-cell row col)
|
|
|
|
|
;;Cell was skipped over - reprint previous
|
|
|
|
|
(ses-goto-print row col)
|
|
|
|
|
(backward-char 1)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let ((rowcol (ses-sym-rowcol (ses--cell-at-pos (point)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-print-cell (car rowcol) (cdr rowcol)))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; The data area
|
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(defun ses-widen ()
|
|
|
|
|
"Turn off narrowing, to be reenabled at end of command loop."
|
2012-09-07 08:58:31 +00:00
|
|
|
|
(if (buffer-narrowed-p)
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(setq ses--deferred-narrow t))
|
|
|
|
|
(widen))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-goto-data (def &optional col)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"Move point to data area for (DEF,COL). If DEF is a row
|
|
|
|
|
number, COL is the column number for a data cell -- otherwise DEF
|
|
|
|
|
is one of the symbols ses--col-widths, ses--col-printers,
|
|
|
|
|
ses--default-printer, ses--numrows, or ses--numcols."
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(ses-widen)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(if col
|
|
|
|
|
;; It's a cell.
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char ses--data-marker)
|
|
|
|
|
(forward-line (+ 1 (* def (1+ ses--numcols)) col)))
|
|
|
|
|
;; Convert def-symbol to offset.
|
|
|
|
|
(setq def (plist-get ses-paramlines-plist def))
|
|
|
|
|
(or def (signal 'args-out-of-range nil))
|
|
|
|
|
(goto-char ses--params-marker)
|
|
|
|
|
(forward-line def)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2014-09-11 19:44:25 +00:00
|
|
|
|
(defun ses-file-format-extend-parameter-list (new-file-format)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
"Extend the global parameters list when file format is updated
|
|
|
|
|
from 2 to 3. This happens when local printer function are added
|
|
|
|
|
to a sheet that was created with SES version 2. This is not
|
lisp/*.el, src/*.c: Fix typos in docstrings
* lisp/apropos.el (apropos-do-all):
* lisp/auth-source-pass.el (auth-source-pass--select-from-entries):
* lisp/auth-source.el (auth-source-user-or-password):
* lisp/calc/calc-forms.el (math-tzone-names):
* lisp/calendar/diary-lib.el (diary-face-attrs)
(diary-mark-entries-1):
* lisp/cedet/cedet-files.el (cedet-files-list-recursively):
* lisp/cedet/ede.el (ede-constructing, ede-deep-rescan):
* lisp/cedet/ede/cpp-root.el (ede-cpp-root-header-file-p):
* lisp/cedet/ede/proj.el (ede-proj-target-makefile):
* lisp/cedet/inversion.el (inversion-check-version)
(inversion-test):
* lisp/cedet/mode-local.el (mode-local-map-file-buffers):
* lisp/cedet/semantic/complete.el (semantic-displayer-ghost):
* lisp/cedet/semantic/db-find.el (semanticdb-find-translate-path-default):
* lisp/cedet/semantic/db.el (semanticdb-table)
(semanticdb-search-system-databases):
* lisp/cedet/semantic/imenu.el (semantic-imenu-index-directory):
* lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map):
* lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-use-headers-flag):
* lisp/cedet/semantic/lex.el (semantic-lex-make-keyword-table)
(semantic-lex-make-type-table, semantic-lex-debug-analyzers):
* lisp/cedet/semantic/tag-ls.el (semantic-tag-abstract-p)
(semantic-tag-leaf-p, semantic-tag-static-p)
(semantic-tag-prototype-p):
* lisp/dnd.el (dnd-open-remote-file-function, dnd-open-local-file):
* lisp/emacs-lisp/eieio-opt.el (eieio-build-class-alist)
(eieio-read-class, eieio-read-subclass):
* lisp/emacs-lisp/generator.el (cps--replace-variable-references)
(cps--handle-loop-for):
* lisp/erc/erc-dcc.el (erc-dcc-list, erc-dcc-member, erc-dcc-server)
(erc-dcc-auto-mask-p, erc-dcc-get-file, erc-dcc-chat-accept):
* lisp/eshell/em-pred.el (eshell-pred-file-type):
* lisp/faces.el (defined-colors-with-face-attributes):
* lisp/font-core.el (font-lock-mode):
* lisp/frame.el (frame-restack):
* lisp/net/shr.el (shr-image-animate):
* lisp/org/org-agenda.el (org-agenda-change-all-lines)
(org-agenda-today-p):
* lisp/org/org-id.el (org-id-get):
* lisp/org/org.el (org-highlight-latex-and-related)
(org--valid-property-p):
* lisp/org/ox-beamer.el (org-beamer--get-label):
* lisp/org/ox-latex.el (org-latex--caption-above-p):
* lisp/org/ox-odt.el (org-odt--copy-image-file)
(org-odt--copy-formula-file):
* lisp/org/ox.el (org-export-with-timestamps):
* lisp/progmodes/verilog-mode.el (verilog-indent-declaration-macros):
* lisp/ses.el (ses-file-format-extend-parameter-list):
* lisp/term.el (ansi-term):
* lisp/textmodes/bibtex.el (bibtex-no-opt-remove-re)
(bibtex-beginning-of-first-entry, bibtex-autokey-get-title)
(bibtex-read-key, bibtex-initialize):
* lisp/textmodes/flyspell.el (flyspell-word):
* lisp/view.el (view-mode-exit):
* src/composite.c:
* src/floatfns.c (Fisnan): Fix typos in docstrings.
2019-09-19 02:32:25 +00:00
|
|
|
|
undoable. Return nil when there was no change, and non-nil otherwise."
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(cond
|
|
|
|
|
((and (= ses--file-format 2) (= 3 new-file-format))
|
|
|
|
|
(ses-set-parameter 'ses--file-format 3)
|
|
|
|
|
(message "Upgrading from SES-2 to SES-3 file format")
|
|
|
|
|
(ses-widen)
|
|
|
|
|
(goto-char ses--params-marker)
|
|
|
|
|
(forward-line (plist-get ses-paramlines-plist 'ses--numlocprn ))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(insert (format (plist-get ses-paramfmt-plist 'ses--numlocprn)
|
|
|
|
|
ses--numlocprn)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
?\n)
|
|
|
|
|
t) )))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-set-parameter (def value &optional elem)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Set parameter DEF to VALUE (with undo) and write the value to the data area.
|
|
|
|
|
See `ses-goto-data' for meaning of DEF. Newlines in the data are escaped.
|
|
|
|
|
If ELEM is specified, it is the array subscript within DEF to be set to VALUE."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(save-excursion
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We call ses-goto-data early, using the old values of numrows and numcols
|
|
|
|
|
;; in case one of them is being changed.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-goto-data def)
|
|
|
|
|
(let ((inhibit-read-only t)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(fmt (plist-get ses-paramfmt-plist
|
2006-05-26 17:39:06 +00:00
|
|
|
|
def))
|
|
|
|
|
oldval)
|
|
|
|
|
(if elem
|
|
|
|
|
(progn
|
|
|
|
|
(setq oldval (aref (symbol-value def) elem))
|
|
|
|
|
(aset (symbol-value def) elem value))
|
|
|
|
|
(setq oldval (symbol-value def))
|
|
|
|
|
(set def value))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Special undo since it's outside the narrowed buffer.
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(let (buffer-undo-list)
|
|
|
|
|
(delete-region (point) (line-end-position))
|
|
|
|
|
(insert (format fmt (symbol-value def))))
|
|
|
|
|
(push `(apply ses-set-parameter ,def ,oldval ,elem) buffer-undo-list))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-write-cells ()
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Write cells in `ses--deferred-write' from local variables to data area.
|
|
|
|
|
Newlines in the data are escaped."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let* ((inhibit-read-only t)
|
|
|
|
|
(print-escape-newlines t)
|
|
|
|
|
rowcol row col cell sym formula printer text)
|
|
|
|
|
(setq ses-start-time (float-time))
|
|
|
|
|
(with-temp-message " "
|
|
|
|
|
(save-excursion
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(while ses--deferred-write
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(ses--time-check "Writing... (%d cells left)"
|
|
|
|
|
(length ses--deferred-write))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq rowcol (pop ses--deferred-write)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
row (car rowcol)
|
|
|
|
|
col (cdr rowcol)
|
|
|
|
|
cell (ses-get-cell row col)
|
|
|
|
|
sym (ses-cell-symbol cell)
|
|
|
|
|
formula (ses-cell-formula cell)
|
|
|
|
|
printer (ses-cell-printer cell))
|
|
|
|
|
(if (eq (car-safe formula) 'ses-safe-formula)
|
|
|
|
|
(setq formula (cadr formula)))
|
|
|
|
|
(if (eq (car-safe printer) 'ses-safe-printer)
|
|
|
|
|
(setq printer (cadr printer)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setq text (prin1-to-string
|
|
|
|
|
;; We could shorten it to (ses-cell SYM VAL) when
|
|
|
|
|
;; the other parameters are nil, but in practice most
|
|
|
|
|
;; cells have non-nil `references', so it's
|
|
|
|
|
;; rather pointless.
|
|
|
|
|
`(ses-cell ,sym
|
|
|
|
|
,(symbol-value sym)
|
|
|
|
|
,(unless (equal formula (symbol-value sym))
|
|
|
|
|
formula)
|
|
|
|
|
,printer
|
|
|
|
|
,(ses-cell-references cell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-goto-data row col)
|
2019-07-28 14:45:22 +00:00
|
|
|
|
(let ((inhibit-quit t))
|
|
|
|
|
(delete-region (point) (line-end-position))
|
|
|
|
|
(insert text))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(message " "))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Formula relocation
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-formula-references (formula &optional result-so-far)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Produce a list of symbols for cells that this FORMULA's value
|
2011-06-27 06:02:27 +00:00
|
|
|
|
refers to. For recursive calls, RESULT-SO-FAR is the list being
|
|
|
|
|
constructed, or t to get a wrong-type-argument error when the
|
|
|
|
|
first reference is found."
|
|
|
|
|
(if (ses-sym-rowcol formula)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
;; Entire formula is one symbol.
|
|
|
|
|
(cl-pushnew formula result-so-far :test #'equal)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(if (consp formula)
|
|
|
|
|
(cond
|
|
|
|
|
((eq (car formula) 'ses-range)
|
|
|
|
|
(dolist (cur
|
|
|
|
|
(cdr (funcall 'macroexpand
|
|
|
|
|
(list 'ses-range (nth 1 formula)
|
|
|
|
|
(nth 2 formula)))))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew cur result-so-far :test #'equal)))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
((null (eq (car formula) 'quote))
|
|
|
|
|
;;Recursive call for subformulas
|
|
|
|
|
(dolist (cur formula)
|
|
|
|
|
(setq result-so-far (ses-formula-references cur result-so-far))))
|
|
|
|
|
(t
|
|
|
|
|
;;Ignore other stuff
|
|
|
|
|
))
|
|
|
|
|
;; other type of atom are ignored
|
|
|
|
|
))
|
|
|
|
|
result-so-far)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(defsubst ses-relocate-symbol (sym rowcol startrow startcol rowincr colincr)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Relocate one symbol SYM, which corresponds to ROWCOL (a cons of ROW and
|
2006-09-29 02:42:39 +00:00
|
|
|
|
COL). Cells starting at (STARTROW,STARTCOL) are being shifted
|
|
|
|
|
by (ROWINCR,COLINCR)."
|
|
|
|
|
(let ((row (car rowcol))
|
|
|
|
|
(col (cdr rowcol)))
|
|
|
|
|
(if (or (< row startrow) (< col startcol))
|
|
|
|
|
sym
|
|
|
|
|
(setq row (+ row rowincr)
|
|
|
|
|
col (+ col colincr))
|
|
|
|
|
(if (and (>= row startrow) (>= col startcol)
|
|
|
|
|
(< row ses--numrows) (< col ses--numcols))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;;Relocate this variable, unless it is a named cell
|
|
|
|
|
(if (eq (get sym 'ses-cell) :ses-named)
|
|
|
|
|
sym
|
2017-06-23 09:16:37 +00:00
|
|
|
|
;; otherwise, we create the relocated cell symbol because
|
|
|
|
|
;; ses-cell-symbol gives the old symbols, however since
|
|
|
|
|
;; renamed cell are not relocated we keep the relocated
|
|
|
|
|
;; cell old symbol in this case.
|
|
|
|
|
(if (eq (get (setq sym (ses-cell-symbol row col)) 'ses-cell) :ses-named)
|
|
|
|
|
sym
|
|
|
|
|
(ses-create-cell-symbol row col)))
|
2006-09-29 02:42:39 +00:00
|
|
|
|
;;Delete reference to a deleted cell
|
|
|
|
|
nil))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-relocate-formula (formula startrow startcol rowincr colincr)
|
|
|
|
|
"Produce a copy of FORMULA where all symbols that refer to cells in row
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
STARTROW or above, and col STARTCOL or above, are altered by adding ROWINCR
|
|
|
|
|
and COLINCR. STARTROW and STARTCOL are 0-based. Example:
|
2015-09-02 01:21:42 +00:00
|
|
|
|
(ses-relocate-formula \\='(+ A1 B2 D3) 1 2 1 -1)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
=> (+ A1 B2 C4)
|
|
|
|
|
If ROWINCR or COLINCR is negative, references to cells being deleted are
|
|
|
|
|
removed. Example:
|
2015-09-02 01:21:42 +00:00
|
|
|
|
(ses-relocate-formula \\='(+ A1 B2 D3) 0 1 0 -1)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
=> (+ A1 C3)
|
2015-11-17 23:28:50 +00:00
|
|
|
|
Sets `ses-relocate-return' to `delete' if cell-references were removed."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let (rowcol result)
|
|
|
|
|
(if (or (atom formula) (eq (car formula) 'quote))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(if (setq rowcol (ses-sym-rowcol formula))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-relocate-symbol formula rowcol
|
|
|
|
|
startrow startcol rowincr colincr)
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; Constants pass through as-is.
|
|
|
|
|
formula)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dolist (cur formula)
|
|
|
|
|
(setq rowcol (ses-sym-rowcol cur))
|
|
|
|
|
(cond
|
|
|
|
|
(rowcol
|
|
|
|
|
(setq cur (ses-relocate-symbol cur rowcol
|
|
|
|
|
startrow startcol rowincr colincr))
|
|
|
|
|
(if cur
|
|
|
|
|
(push cur result)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Reference to a deleted cell. Set a flag in ses-relocate-return.
|
|
|
|
|
;; don't change the flag if it's already 'range, since range implies
|
|
|
|
|
;; 'delete.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(unless ses-relocate-return
|
|
|
|
|
(setq ses-relocate-return 'delete))))
|
|
|
|
|
((eq (car-safe cur) 'ses-range)
|
|
|
|
|
(setq cur (ses-relocate-range cur startrow startcol rowincr colincr))
|
|
|
|
|
(if cur
|
|
|
|
|
(push cur result)))
|
|
|
|
|
((or (atom cur) (eq (car cur) 'quote))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Constants pass through unchanged.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push cur result))
|
|
|
|
|
(t
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Recursively copy and alter subformulas.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push (ses-relocate-formula cur startrow startcol
|
|
|
|
|
rowincr colincr)
|
|
|
|
|
result))))
|
|
|
|
|
(nreverse result))))
|
|
|
|
|
|
|
|
|
|
(defun ses-relocate-range (range startrow startcol rowincr colincr)
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
"Relocate one RANGE, of the form (ses-range MIN MAX). Cells starting
|
2002-09-28 18:45:56 +00:00
|
|
|
|
at (STARTROW,STARTCOL) are being shifted by (ROWINCR,COLINCR). Result is the
|
|
|
|
|
new range, or nil if the entire range is deleted. If new rows are being added
|
|
|
|
|
just beyond the end of a row range, or new columns just beyond a column range,
|
|
|
|
|
the new rows/columns will be added to the range. Sets `ses-relocate-return'
|
|
|
|
|
if the range was altered."
|
|
|
|
|
(let* ((minorig (cadr range))
|
|
|
|
|
(minrowcol (ses-sym-rowcol minorig))
|
|
|
|
|
(min (ses-relocate-symbol minorig minrowcol
|
|
|
|
|
startrow startcol
|
|
|
|
|
rowincr colincr))
|
|
|
|
|
(maxorig (nth 2 range))
|
|
|
|
|
(maxrowcol (ses-sym-rowcol maxorig))
|
|
|
|
|
(max (ses-relocate-symbol maxorig maxrowcol
|
|
|
|
|
startrow startcol
|
|
|
|
|
rowincr colincr))
|
|
|
|
|
field)
|
|
|
|
|
(cond
|
|
|
|
|
((and (not min) (not max))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(setq range nil)) ; The entire range is deleted.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
((zerop colincr)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Inserting or deleting rows.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq field 'car)
|
|
|
|
|
(if (not min)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Chopped off beginning of range.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq min (ses-create-cell-symbol startrow (cdr minrowcol))
|
|
|
|
|
ses-relocate-return 'range))
|
|
|
|
|
(if (not max)
|
|
|
|
|
(if (> rowincr 0)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Trying to insert a nonexistent row.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (1- ses--numrows)
|
|
|
|
|
(cdr minrowcol)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; End of range is being deleted.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (1- startrow) (cdr minrowcol))
|
|
|
|
|
ses-relocate-return 'range))
|
|
|
|
|
(and (> rowincr 0)
|
|
|
|
|
(= (car maxrowcol) (1- startrow))
|
|
|
|
|
(= (cdr minrowcol) (cdr maxrowcol))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insert after ending row of vertical range --- include it.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (+ startrow rowincr -1)
|
|
|
|
|
(cdr maxrowcol))))))
|
|
|
|
|
(t
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Inserting or deleting columns.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq field 'cdr)
|
|
|
|
|
(if (not min)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Chopped off beginning of range.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq min (ses-create-cell-symbol (car minrowcol) startcol)
|
|
|
|
|
ses-relocate-return 'range))
|
|
|
|
|
(if (not max)
|
|
|
|
|
(if (> colincr 0)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Trying to insert a nonexistent column.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (car maxrowcol)
|
|
|
|
|
(1- ses--numcols)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; End of range is being deleted.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (car maxrowcol) (1- startcol))
|
|
|
|
|
ses-relocate-return 'range))
|
|
|
|
|
(and (> colincr 0)
|
|
|
|
|
(= (cdr maxrowcol) (1- startcol))
|
|
|
|
|
(= (car minrowcol) (car maxrowcol))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insert after ending column of horizontal range --- include it.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq max (ses-create-cell-symbol (car maxrowcol)
|
|
|
|
|
(+ startcol colincr -1)))))))
|
|
|
|
|
(when range
|
|
|
|
|
(if (/= (- (funcall field maxrowcol)
|
|
|
|
|
(funcall field minrowcol))
|
|
|
|
|
(- (funcall field (ses-sym-rowcol max))
|
|
|
|
|
(funcall field (ses-sym-rowcol min))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; This range has changed size.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq ses-relocate-return 'range))
|
2021-07-28 11:42:05 +00:00
|
|
|
|
`(ses-range ,min ,max ,@(cdddr range)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-relocate-all (minrow mincol rowincr colincr)
|
|
|
|
|
"Alter all cell values, symbols, formulas, and reference-lists to relocate
|
|
|
|
|
the rectangle (MINROW,MINCOL)..(NUMROWS,NUMCOLS) by adding ROWINCR and COLINCR
|
|
|
|
|
to each symbol."
|
|
|
|
|
(let (reform)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(let (mycell newval xrow)
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(row ses--numrows) "Relocating formulas..."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq ses-relocate-return nil
|
|
|
|
|
mycell (ses-get-cell row col)
|
|
|
|
|
newval (ses-relocate-formula (ses-cell-formula mycell)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
minrow mincol rowincr colincr)
|
|
|
|
|
xrow (- row rowincr))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row col 'formula newval)
|
|
|
|
|
(if (eq ses-relocate-return 'range)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; This cell contains a (ses-range X Y) where a cell has been
|
|
|
|
|
;; inserted or deleted in the middle of the range.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push (cons row col) reform))
|
|
|
|
|
(if ses-relocate-return
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; This cell referred to a cell that's been deleted or is no
|
|
|
|
|
;; longer part of the range. We can't fix that now because
|
|
|
|
|
;; reference lists cells have been partially updated.
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew (ses-create-cell-symbol row col)
|
|
|
|
|
ses--deferred-recalc :test #'equal))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq newval (ses-relocate-formula (ses-cell-references mycell)
|
|
|
|
|
minrow mincol rowincr colincr))
|
|
|
|
|
(ses-set-cell row col 'references newval)
|
|
|
|
|
(and (>= row minrow) (>= col mincol)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(let ((sym (ses-cell-symbol row col))
|
|
|
|
|
(xcol (- col colincr)))
|
|
|
|
|
(if (and
|
|
|
|
|
sym
|
|
|
|
|
(>= xrow 0)
|
|
|
|
|
(>= xcol 0)
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; the following could also be tested as
|
|
|
|
|
;; (null (eq sym (ses-create-cell-symbol xrow xcol)))
|
|
|
|
|
(eq (get sym 'ses-cell) :ses-named))
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
;; This is a renamed cell, do not update the cell
|
|
|
|
|
;; name, but just update the coordinate property.
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(puthash sym (cons row col) ses--named-cell-hashmap)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(ses-set-cell row col 'symbol
|
|
|
|
|
(setq sym (ses-create-cell-symbol row col)))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(unless (local-variable-if-set-p sym)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(set (make-local-variable sym) nil)
|
|
|
|
|
(put sym 'ses-cell (cons row col)))))) )))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Relocate the cell values.
|
2017-07-13 18:58:22 +00:00
|
|
|
|
(let (oldval myrow mycol xrow xcol sym)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(cond
|
|
|
|
|
((and (<= rowincr 0) (<= colincr 0))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Deletion of rows and/or columns.
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(row (- ses--numrows minrow)) "Relocating variables..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq myrow (+ row minrow))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col (- ses--numcols mincol))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq mycol (+ col mincol)
|
|
|
|
|
xrow (- myrow rowincr)
|
2017-07-13 18:58:22 +00:00
|
|
|
|
xcol (- mycol colincr)
|
|
|
|
|
sym (ses-cell-symbol myrow mycol))
|
|
|
|
|
;; We don't need to relocate value for renamed cells, as they keep the same
|
|
|
|
|
;; symbol.
|
|
|
|
|
(unless (eq (get sym 'ses-cell) :ses-named)
|
|
|
|
|
(ses-set-cell myrow mycol 'value
|
|
|
|
|
(if (and (< xrow ses--numrows) (< xcol ses--numcols))
|
|
|
|
|
(ses-cell-value xrow xcol)
|
|
|
|
|
;; Cell is off the end of the array.
|
|
|
|
|
(symbol-value (ses-create-cell-symbol xrow xcol)))))))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(when ses--in-killing-named-cell-list
|
|
|
|
|
(message "Unbinding killed named cell symbols...")
|
|
|
|
|
(setq ses-start-time (float-time))
|
|
|
|
|
(while ses--in-killing-named-cell-list
|
|
|
|
|
(ses--time-check "Unbinding killed named cell symbols... (%d left)" (length ses--in-killing-named-cell-list))
|
|
|
|
|
(ses--unbind-cell-name (pop ses--in-killing-named-cell-list)) )
|
|
|
|
|
(message nil)) )
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
((and (wholenump rowincr) (wholenump colincr))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insertion of rows and/or columns. Run the loop backwards.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((disty (1- ses--numrows))
|
|
|
|
|
(distx (1- ses--numcols))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
myrow mycol)
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter
|
|
|
|
|
(row (- ses--numrows minrow)) "Relocating variables..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq myrow (- disty row))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col (- ses--numcols mincol))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq mycol (- distx col)
|
|
|
|
|
xrow (- myrow rowincr)
|
2017-07-13 18:58:22 +00:00
|
|
|
|
xcol (- mycol colincr)
|
|
|
|
|
sym (ses-cell-symbol myrow mycol))
|
|
|
|
|
;; We don't need to relocate value for renamed cells, as they keep the same
|
|
|
|
|
;; symbol.
|
|
|
|
|
(unless (eq (get sym 'ses-cell) :ses-named)
|
|
|
|
|
(if (or (< xrow minrow) (< xcol mincol))
|
|
|
|
|
;; Newly-inserted value.
|
|
|
|
|
(setq oldval nil)
|
|
|
|
|
;; Transfer old value.
|
|
|
|
|
(setq oldval (ses-cell-value xrow xcol)))
|
|
|
|
|
(ses-set-cell myrow mycol 'value oldval))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
t)) ; Make testcover happy by returning non-nil here.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(t
|
|
|
|
|
(error "ROWINCR and COLINCR must have the same sign"))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Reconstruct reference lists for cells that contain ses-ranges that have
|
|
|
|
|
;; changed size.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(when reform
|
|
|
|
|
(message "Fixing ses-ranges...")
|
|
|
|
|
(let (row col)
|
|
|
|
|
(setq ses-start-time (float-time))
|
|
|
|
|
(while reform
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(ses--time-check "Fixing ses-ranges... (%d left)" (length reform))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq row (caar reform)
|
|
|
|
|
col (cdar reform)
|
|
|
|
|
reform (cdr reform))
|
|
|
|
|
(ses-cell-set-formula row col (ses-cell-formula row col))))
|
|
|
|
|
(message nil))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Undo control
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-begin-change ()
|
2005-01-29 17:31:32 +00:00
|
|
|
|
"For undo, remember point before we start changing hidden stuff."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(insert-and-inherit "X")
|
|
|
|
|
(delete-region (1- (point)) (point))))
|
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(defun ses-setter-with-undo (accessors newval &rest args)
|
|
|
|
|
"Set a field/variable and record it so it can be undone.
|
|
|
|
|
Result is non-nil if field/variable has changed."
|
|
|
|
|
(let ((oldval (apply (car accessors) args)))
|
|
|
|
|
(unless (equal-including-properties oldval newval)
|
|
|
|
|
(push `(apply ses-setter-with-undo ,accessors ,oldval ,@args)
|
|
|
|
|
buffer-undo-list)
|
|
|
|
|
(apply (cdr accessors) newval args)
|
|
|
|
|
t)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-aset-with-undo (array idx newval)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(ses-setter-with-undo (eval-when-compile
|
|
|
|
|
(cons #'aref
|
|
|
|
|
(lambda (newval array idx) (aset array idx newval))))
|
|
|
|
|
newval array idx))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(defun ses-set-with-undo (sym newval)
|
|
|
|
|
(ses-setter-with-undo
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(cons (lambda (sym) (if (boundp sym) (symbol-value sym) :ses--unbound))
|
|
|
|
|
(lambda (newval sym) (if (eq newval :ses--unbound)
|
|
|
|
|
(makunbound sym)
|
|
|
|
|
(set sym newval)))))
|
|
|
|
|
newval sym))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Startup for major mode
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-load ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Parse the current buffer and set up buffer-local variables.
|
|
|
|
|
Does not execute cell formulas or print functions."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(widen)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Read our global parameters, which should be a 3-element list.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(goto-char (point-max))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(search-backward ";; Local Variables:\n" nil t)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(backward-list 1)
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(setq ses--params-marker (point-marker))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(let* ((params (ignore-errors (read (current-buffer))))
|
|
|
|
|
(params-len (safe-length params)))
|
|
|
|
|
(or (and (>= params-len 3)
|
|
|
|
|
(<= params-len 4)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(numberp (car params))
|
|
|
|
|
(numberp (cadr params))
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(>= (cadr params) 0)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(numberp (nth 2 params))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(> (nth 2 params) 0)
|
|
|
|
|
(or (<= params-len 3)
|
2014-09-11 19:44:25 +00:00
|
|
|
|
(let ((numlocprn (nth 3 params)))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(and (integerp numlocprn) (>= numlocprn 0)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Invalid SES file"))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--file-format (car params)
|
|
|
|
|
ses--numrows (cadr params)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
ses--numcols (nth 2 params)
|
|
|
|
|
ses--numlocprn (or (nth 3 params) 0))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when (= ses--file-format 1)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(let (buffer-undo-list) ; This is not undoable.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-goto-data 'ses--header-row)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert "(ses-header-row 0)\n")
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(ses-set-parameter 'ses--file-format 3)
|
|
|
|
|
(message "Upgrading from SES-1 to SES-2 file format")))
|
|
|
|
|
(or (<= ses--file-format 3)
|
2005-06-14 15:20:47 +00:00
|
|
|
|
(error "This file needs a newer version of the SES library code"))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Initialize cell array.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--cells (make-vector ses--numrows nil))
|
|
|
|
|
(dotimes (row ses--numrows)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(aset ses--cells row (make-vector ses--numcols nil)))
|
|
|
|
|
;; initialize local printer map.
|
|
|
|
|
(clrhash ses--local-printer-hashmap))
|
|
|
|
|
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Skip over print area, which we assume is correct.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line ses--numrows)
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(or (looking-at-p ses-print-data-boundary)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Missing marker between print and data areas"))
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(forward-char 1)
|
|
|
|
|
(setq ses--data-marker (point-marker))
|
|
|
|
|
(forward-char (1- (length ses-print-data-boundary)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Initialize printer and symbol lists.
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(mapc #'ses-printer-record ses-standard-printer-functions)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(setq ses--symbolic-formulas nil)
|
|
|
|
|
|
2014-09-11 19:44:25 +00:00
|
|
|
|
;; Load local printer definitions.
|
|
|
|
|
;; This must be loaded *BEFORE* cells and column printers because the latter
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; may call them.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line (* ses--numrows (1+ ses--numcols)))
|
|
|
|
|
(let ((numlocprn ses--numlocprn))
|
|
|
|
|
(setq ses--numlocprn 0)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(dotimes (_ numlocprn)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(let ((x (read (current-buffer))))
|
2017-07-07 03:53:19 +00:00
|
|
|
|
(or (and (= (following-char) ?\n)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(eq (car-safe x) 'ses-local-printer)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(apply #'ses--local-printer (cdr x)))
|
2021-09-14 06:43:18 +00:00
|
|
|
|
(error "Local printer-def error"))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(setq ses--numlocprn (1+ ses--numlocprn))))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Load cell definitions.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let* ((x (read (current-buffer)))
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(sym (car-safe (cdr-safe x))))
|
2017-07-07 03:53:19 +00:00
|
|
|
|
(or (and (= (following-char) ?\n)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(eq (car-safe x) 'ses-cell)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(ses-create-cell-variable sym row col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Cell-def error"))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(apply #'ses--cell (cdr x))))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(or (looking-at-p "\n\n")
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Missing blank line between rows")))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; Skip local printer function declaration --- that were already loaded.
|
|
|
|
|
(forward-line (+ 2 ses--numlocprn))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Load global parameters.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((widths (read (current-buffer)))
|
|
|
|
|
(n1 (char-after (point)))
|
|
|
|
|
(printers (read (current-buffer)))
|
|
|
|
|
(n2 (char-after (point)))
|
|
|
|
|
(def-printer (read (current-buffer)))
|
|
|
|
|
(n3 (char-after (point)))
|
|
|
|
|
(head-row (read (current-buffer)))
|
|
|
|
|
(n4 (char-after (point))))
|
|
|
|
|
(or (and (eq (car-safe widths) 'ses-column-widths)
|
|
|
|
|
(= n1 ?\n)
|
|
|
|
|
(eq (car-safe printers) 'ses-column-printers)
|
|
|
|
|
(= n2 ?\n)
|
|
|
|
|
(eq (car-safe def-printer) 'ses-default-printer)
|
|
|
|
|
(= n3 ?\n)
|
|
|
|
|
(eq (car-safe head-row) 'ses-header-row)
|
|
|
|
|
(= n4 ?\n))
|
|
|
|
|
(error "Invalid SES global parameters"))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(1value (eval widths t))
|
|
|
|
|
(1value (eval def-printer t))
|
|
|
|
|
(1value (eval printers t))
|
|
|
|
|
(1value (eval head-row t)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Should be back at global-params.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(forward-char 1)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(or (looking-at-p ses-initial-global-parameters-re)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Problem with column-defs or global-params"))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Check for overall newline count in definitions area.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(forward-line 3)
|
|
|
|
|
(let ((start (point)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-goto-data 'ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (= (point) start)
|
|
|
|
|
(error "Extraneous newlines someplace?"))))
|
|
|
|
|
|
|
|
|
|
(defun ses-setup ()
|
|
|
|
|
"Set up for display of only the printed cell values.
|
|
|
|
|
|
|
|
|
|
Narrows the buffer to show only the print area. Gives it `read-only' and
|
|
|
|
|
`intangible' properties. Sets up highlighting for current cell."
|
|
|
|
|
(interactive)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((end (point-min))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
pos sym)
|
2014-09-30 15:33:03 +00:00
|
|
|
|
(with-silent-modifications
|
|
|
|
|
(ses-goto-data 0 0) ; Include marker between print-area and data-area.
|
|
|
|
|
(set-text-properties (point) (point-max) nil) ; Delete garbage props.
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(mapc #'delete-overlay (overlays-in (point-min) (point-max)))
|
2014-09-30 15:33:03 +00:00
|
|
|
|
;; The print area is read-only (except for our special commands) and
|
|
|
|
|
;; uses a special keymap.
|
|
|
|
|
(put-text-property (point-min) (1- (point)) 'read-only 'ses)
|
|
|
|
|
(put-text-property (point-min) (1- (point)) 'keymap 'ses-mode-print-map)
|
|
|
|
|
;; For the beginning of the buffer, we want the read-only and keymap
|
|
|
|
|
;; attributes to be inherited from the first character.
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(put-text-property (point-min) (1+ (point-min))
|
|
|
|
|
;; `cursor-intangible' shouldn't be sticky at BOB.
|
|
|
|
|
'front-sticky '(read-only keymap))
|
2014-09-30 15:33:03 +00:00
|
|
|
|
;; Create intangible properties, which also indicate which cell the text
|
|
|
|
|
;; came from.
|
|
|
|
|
(dotimes-with-progress-reporter (row ses--numrows) "Finding cells..."
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(setq pos end
|
|
|
|
|
sym (ses-cell-symbol row col))
|
|
|
|
|
(unless (eq (symbol-value sym) '*skip*)
|
|
|
|
|
;; Include skipped cells following this one.
|
|
|
|
|
(while (and (< col (1- ses--numcols))
|
|
|
|
|
(eq (ses-cell-value row (1+ col)) '*skip*))
|
|
|
|
|
(setq end (+ end (ses-col-width col) 1)
|
|
|
|
|
;; Beware: Modifying the iteration variable of `dotimes'
|
|
|
|
|
;; may or may not affect the iteration!
|
|
|
|
|
col (1+ col)))
|
|
|
|
|
(setq end (save-excursion
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(move-to-column (+ (current-column) (- end pos)
|
|
|
|
|
(ses-col-width col)))
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(+ end (ses-col-width col) 1)
|
|
|
|
|
(forward-char)
|
|
|
|
|
(point))))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(put-text-property pos end 'cursor-intangible sym))))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Create the underlining overlay. It's impossible for (point) to be 2,
|
|
|
|
|
;; because column A must be at least 1 column wide.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--curcell-overlay (make-overlay (1+ (point-min)) (1+ (point-min))))
|
|
|
|
|
(overlay-put ses--curcell-overlay 'face 'underline))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-cleanup ()
|
2007-07-23 21:49:42 +00:00
|
|
|
|
"Cleanup when changing a buffer from SES mode to something else.
|
|
|
|
|
Delete overlays, remove special text properties."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(widen)
|
|
|
|
|
(let ((inhibit-read-only t)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; When reverting, hide the buffer name, otherwise Emacs will ask the
|
|
|
|
|
;; user "the file is modified, do you really want to make modifications
|
|
|
|
|
;; to this buffer", where the "modifications" refer to the irrelevant
|
|
|
|
|
;; set-text-properties below.
|
|
|
|
|
(buffer-file-name nil)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(was-modified (buffer-modified-p)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Delete read-only, keymap, and intangible properties.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(set-text-properties (point-min) (point-max) nil)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Delete overlay.
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(mapc #'delete-overlay (overlays-in (point-min) (point-max)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(unless was-modified
|
2007-07-23 21:49:42 +00:00
|
|
|
|
(restore-buffer-modified-p nil))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(defun ses-killbuffer-hook ()
|
|
|
|
|
"Hook when the current buffer is killed."
|
|
|
|
|
(setq ses--ses-buffer-list (delq (current-buffer) ses--ses-buffer-list)))
|
|
|
|
|
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun ses-mode ()
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"Major mode for Simple Emacs Spreadsheet.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2013-11-20 08:16:20 +00:00
|
|
|
|
When you invoke SES in a new buffer, it is divided into cells
|
|
|
|
|
that you can enter data into. You can navigate the cells with
|
|
|
|
|
the arrow keys and add more cells with the tab key. The contents
|
2021-04-25 11:12:48 +00:00
|
|
|
|
of these cells can be numbers, text, or Lisp expressions. (To
|
2013-11-20 08:16:20 +00:00
|
|
|
|
enter text, enclose it in double quotes.)
|
|
|
|
|
|
|
|
|
|
In an expression, you can use cell coordinates to refer to the
|
|
|
|
|
contents of another cell. For example, you can sum a range of
|
|
|
|
|
cells with `(+ A1 A2 A3)'. There are specialized functions like
|
|
|
|
|
`ses+' (addition for ranges with empty cells), `ses-average' (for
|
|
|
|
|
performing calculations on cells), and `ses-range' and `ses-select'
|
|
|
|
|
\(for extracting ranges of cells).
|
|
|
|
|
|
|
|
|
|
Each cell also has a print function that controls how it is
|
|
|
|
|
displayed.
|
|
|
|
|
|
|
|
|
|
Each SES buffer is divided into a print area and a data area.
|
|
|
|
|
Normally, you can simply use SES to look at and manipulate the print
|
|
|
|
|
area, and let SES manage the data area outside the visible region.
|
|
|
|
|
|
|
|
|
|
See \"ses-example.ses\" (in `data-directory') for an example
|
|
|
|
|
spreadsheet, and the Info node `(ses)Top.'
|
|
|
|
|
|
|
|
|
|
In the following, note the separate keymaps for cell editing mode
|
|
|
|
|
and print mode specifications. Key definitions:
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
\\{ses-mode-map}
|
2013-11-20 08:16:20 +00:00
|
|
|
|
These key definitions are active only in the print area (the visible
|
|
|
|
|
part):
|
2002-09-28 18:45:56 +00:00
|
|
|
|
\\{ses-mode-print-map}
|
2013-11-20 08:16:20 +00:00
|
|
|
|
These are active only in the minibuffer, when entering or editing a
|
|
|
|
|
formula:
|
2002-09-28 18:45:56 +00:00
|
|
|
|
\\{ses-mode-edit-map}"
|
|
|
|
|
(interactive)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(unless (and (boundp 'ses--deferred-narrow)
|
|
|
|
|
(eq ses--deferred-narrow 'ses-mode))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(kill-all-local-variables)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-set-localvars)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq major-mode 'ses-mode
|
|
|
|
|
mode-name "SES"
|
|
|
|
|
next-line-add-newlines nil
|
|
|
|
|
truncate-lines t
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; SES deliberately puts lots of trailing whitespace in its buffer.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
show-trailing-whitespace nil
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Cell ranges do not work reasonably without this.
|
2008-05-15 19:24:57 +00:00
|
|
|
|
transient-mark-mode t
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Not to use tab characters for safe (tabs may do bad for column
|
|
|
|
|
;; calculation).
|
2008-05-15 19:24:57 +00:00
|
|
|
|
indent-tabs-mode nil)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(1value (add-hook 'change-major-mode-hook #'ses-cleanup nil t))
|
|
|
|
|
(1value (add-hook 'kill-buffer-hook #'ses-killbuffer-hook nil t))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(cl-pushnew (current-buffer) ses--ses-buffer-list :test 'eq)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
;; This makes revert impossible if the buffer is read-only.
|
|
|
|
|
;; (1value (add-hook 'before-revert-hook 'ses-cleanup nil t))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(setq header-line-format '(:eval (progn
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when (/= (window-hscroll)
|
|
|
|
|
ses--header-hscroll)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Reset ses--header-hscroll first,
|
|
|
|
|
;; to avoid recursion problems when
|
|
|
|
|
;; debugging ses-create-header-string
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--header-hscroll
|
|
|
|
|
(window-hscroll))
|
|
|
|
|
(ses-create-header-string))
|
|
|
|
|
ses--header-string)))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(setq-local mode-line-process '(:eval (ses--mode-line-process)))
|
|
|
|
|
(add-hook 'pre-redisplay-functions #'ses--cursor-sensor-highlight
|
|
|
|
|
;; Highlight the cell after moving cursor out of intangible.
|
|
|
|
|
'append t)
|
|
|
|
|
(cursor-intangible-mode 1)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((was-empty (zerop (buffer-size)))
|
|
|
|
|
(was-modified (buffer-modified-p)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if was-empty
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Initialize buffer to contain one cell, for now.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert ses-initial-file-contents))
|
|
|
|
|
(ses-load)
|
|
|
|
|
(ses-setup))
|
|
|
|
|
(when was-empty
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(unless (equal ses-initial-default-printer
|
|
|
|
|
(1value ses--default-printer))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1value (ses-read-default-printer ses-initial-default-printer)))
|
|
|
|
|
(unless (= ses-initial-column-width (1value (ses-col-width 0)))
|
|
|
|
|
(1value (ses-set-column-width 0 ses-initial-column-width)))
|
|
|
|
|
(ses-set-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (> (car ses-initial-size) (1value ses--numrows))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1value (ses-insert-row (1- (car ses-initial-size)))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (> (cdr ses-initial-size) (1value ses--numcols))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1value (ses-insert-column (1- (cdr ses-initial-size)))))
|
|
|
|
|
(ses-write-cells)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(restore-buffer-modified-p was-modified)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(buffer-disable-undo)
|
|
|
|
|
(buffer-enable-undo)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(use-local-map ses-mode-map)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Set the deferred narrowing flag (we can't narrow until after
|
|
|
|
|
;; after-find-file completes). If .ses is on the auto-load alist and the
|
|
|
|
|
;; file has "mode: ses", our ses-mode function will be called twice! Use a
|
|
|
|
|
;; special flag to detect this (will be reset by ses-command-hook). For
|
|
|
|
|
;; find-alternate-file, post-command-hook doesn't get run for some reason,
|
|
|
|
|
;; so use an idle timer to make sure.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--deferred-narrow 'ses-mode)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(1value (add-hook 'post-command-hook #'ses-command-hook nil t))
|
|
|
|
|
(run-with-idle-timer 0.01 nil #'ses-command-hook)
|
2005-05-26 13:10:29 +00:00
|
|
|
|
(run-mode-hooks 'ses-mode-hook)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(put 'ses-mode 'mode-class 'special)
|
|
|
|
|
|
|
|
|
|
(defun ses-command-hook ()
|
|
|
|
|
"Invoked from `post-command-hook'. If point has moved to a different cell,
|
2021-04-25 11:12:48 +00:00
|
|
|
|
move the underlining overlay. Perform any recalculations or cell-data
|
2002-09-28 18:45:56 +00:00
|
|
|
|
writes that have been deferred. If buffer-narrowing has been deferred,
|
2021-04-25 11:12:48 +00:00
|
|
|
|
narrow the buffer now."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(condition-case err
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(when (eq major-mode 'ses-mode) ; Otherwise, not our buffer anymore.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when ses--deferred-recalc
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We reset the deferred list before starting on the recalc --- in
|
|
|
|
|
;; case of error, we don't want to retry the recalc after every
|
|
|
|
|
;; keystroke!
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-initialize-Dijkstra-attempt)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((old ses--deferred-recalc))
|
|
|
|
|
(setq ses--deferred-recalc nil)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-update-cells old)))
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(when ses--deferred-write
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We don't reset the deferred list before starting --- the most
|
|
|
|
|
;; likely error is keyboard-quit, and we do want to keep trying these
|
|
|
|
|
;; writes after a quit.
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(ses-write-cells)
|
|
|
|
|
(push '(apply ses-widen) buffer-undo-list))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when ses--deferred-narrow
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We're not allowed to narrow the buffer until after-find-file has
|
|
|
|
|
;; read the local variables at the end of the file. Now it's safe to
|
|
|
|
|
;; do the narrowing.
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(narrow-to-region (point-min) ses--data-marker)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(setq ses--deferred-narrow nil)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Prevent errors in this post-command-hook from silently erasing the hook!
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error
|
|
|
|
|
(unless executing-kbd-macro
|
|
|
|
|
(ding))
|
2005-09-18 12:25:02 +00:00
|
|
|
|
(message "%s" (error-message-string err))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
nil) ; Make coverage-tester happy.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(defun ses--mode-line-process ()
|
|
|
|
|
(let ((cmlp (window-parameter nil 'ses--mode-line-process))
|
|
|
|
|
(curcell (ses--curcell (window-point))))
|
|
|
|
|
(if (equal curcell (car cmlp))
|
|
|
|
|
(cdr cmlp)
|
|
|
|
|
(let ((mlp
|
|
|
|
|
(cond
|
|
|
|
|
((not curcell) nil)
|
|
|
|
|
((atom curcell) (list " cell " (symbol-name curcell)))
|
|
|
|
|
(t
|
|
|
|
|
(list " range "
|
|
|
|
|
(symbol-name (car curcell))
|
|
|
|
|
"-"
|
|
|
|
|
(symbol-name (cdr curcell)))))))
|
|
|
|
|
(set-window-parameter nil 'ses--mode-line-process (cons curcell mlp))
|
|
|
|
|
mlp))))
|
|
|
|
|
|
|
|
|
|
(defun ses--cursor-sensor-highlight (window)
|
|
|
|
|
(let ((curcell (ses--curcell))
|
|
|
|
|
(ol (window-parameter window 'ses--curcell-overlay)))
|
|
|
|
|
(unless ol
|
|
|
|
|
(setq ol (make-overlay (point) (point)))
|
|
|
|
|
(overlay-put ol 'window window)
|
|
|
|
|
(overlay-put ol 'face 'underline)
|
|
|
|
|
(set-window-parameter window 'ses--curcell-overlay ol))
|
|
|
|
|
;; Use underline overlay for single-cells only, turn off otherwise.
|
|
|
|
|
(if (listp curcell)
|
|
|
|
|
(delete-overlay ol)
|
|
|
|
|
(let* ((pos (window-point window))
|
|
|
|
|
(next (next-single-property-change pos 'cursor-intangible)))
|
|
|
|
|
(move-overlay ol pos (1- next))))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(defun ses-create-header-string ()
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Set up `ses--header-string' as the buffer's header line.
|
|
|
|
|
Based on the current set of columns and `window-hscroll' position."
|
|
|
|
|
(let ((totwidth (- (window-hscroll)))
|
|
|
|
|
result width x)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Leave room for the left-side fringe and scrollbar.
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(push (propertize " " 'display '((space :align-to 0))) result)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq width (ses-col-width col)
|
|
|
|
|
totwidth (+ totwidth width 1))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(if (= totwidth 1)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Scrolled so intercolumn space is leftmost.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push " " result))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(when (> totwidth 1)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (> ses--header-row 0)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(save-excursion
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-goto-print (1- ses--header-row) col)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq x (buffer-substring-no-properties (point)
|
|
|
|
|
(+ (point) width)))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;; Strip trailing space.
|
|
|
|
|
(if (string-match "[ \t]+\\'" x)
|
|
|
|
|
(setq x (substring x 0 (match-beginning 0))))
|
|
|
|
|
;; Cut off excess text.
|
|
|
|
|
(if (>= (length x) totwidth)
|
|
|
|
|
(setq x (substring x 0 (- totwidth -1)))))
|
|
|
|
|
(setq x (ses-column-letter col)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push (propertize x 'face ses-box-prop) result)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(push (propertize "."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
'display `((space :align-to ,(1- totwidth)))
|
|
|
|
|
'face ses-box-prop)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
result)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Allow the following space to be squished to make room for the 3-D box
|
|
|
|
|
;; Coverage test ignores properties, thinks this is always a space!
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push (1value (propertize " " 'display `((space :align-to ,totwidth))))
|
|
|
|
|
result)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (> ses--header-row 0)
|
|
|
|
|
(push (propertize (format " [row %d]" ses--header-row)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
'display '((height (- 1))))
|
|
|
|
|
result))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq ses--header-string (apply #'concat (nreverse result)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Redisplay and recalculation
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2022-04-04 17:42:07 +00:00
|
|
|
|
(defun ses-jump-prefix (prefix-int)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
"Convert an integer (unversal prefix) into a (ROW . COL).
|
|
|
|
|
Does it by numbering cells starting from 0 from top left to bottom right,
|
|
|
|
|
going row by row."
|
2022-04-04 17:42:07 +00:00
|
|
|
|
(and (>= prefix-int 0)
|
|
|
|
|
(< prefix-int (* ses--numcols ses--numrows))
|
|
|
|
|
(cons (/ prefix-int ses--numcols) (% prefix-int ses--numcols))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2022-04-04 17:42:07 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-jump (&optional sym)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Move point to cell SYM."
|
2022-04-04 17:42:07 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(setq sym
|
|
|
|
|
(if current-prefix-arg
|
|
|
|
|
(funcall ses-jump-prefix-function (prefix-numeric-value sym))
|
|
|
|
|
(or sym
|
|
|
|
|
(completing-read
|
|
|
|
|
"Jump to cell: "
|
|
|
|
|
(and ses--named-cell-hashmap
|
|
|
|
|
(let (names)
|
|
|
|
|
(maphash (lambda (key _val)
|
|
|
|
|
(push (symbol-name key) names))
|
|
|
|
|
ses--named-cell-hashmap)
|
|
|
|
|
names))))))
|
|
|
|
|
(and (stringp sym)
|
|
|
|
|
(not (and ses--named-cell-hashmap (gethash (intern sym) ses--named-cell-hashmap)))
|
|
|
|
|
(setq sym (funcall ses-jump-cell-name-function sym)))
|
|
|
|
|
(if (stringp sym)
|
|
|
|
|
(if (string= sym "")
|
|
|
|
|
(user-error "Empty cell name")
|
|
|
|
|
(setq sym (intern sym))))
|
|
|
|
|
(let ((rowcol (if (consp sym)
|
|
|
|
|
(prog1 sym (setq sym (ses-cell-symbol (car sym) (cdr sym))))
|
|
|
|
|
(ses-sym-rowcol sym))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or rowcol (error "Invalid cell name"))
|
|
|
|
|
(if (eq (symbol-value sym) '*skip*)
|
2022-04-04 17:42:07 +00:00
|
|
|
|
(error "Cell is covered by preceding cell"))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-goto-print (car rowcol) (cdr rowcol))))
|
|
|
|
|
|
|
|
|
|
(defun ses-jump-safe (cell)
|
|
|
|
|
"Like `ses-jump', but no error if invalid cell."
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(ignore-errors
|
|
|
|
|
(ses-jump cell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-reprint-all (&optional nonarrow)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Recreate the display area. Call all printer functions.
|
|
|
|
|
Narrow to print area if optional argument NONARROW is nil."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*P")
|
|
|
|
|
(widen)
|
|
|
|
|
(unless nonarrow
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--deferred-narrow t))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let ((startcell (ses--cell-at-pos (point)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(inhibit-read-only t))
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(search-forward ses-print-data-boundary)
|
|
|
|
|
(backward-char (length ses-print-data-boundary))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(delete-region (point-min) (point))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insert all blank lines before printing anything, so ses-print-cell can
|
|
|
|
|
;; find the data area when inserting or deleting *skip* values for cells.
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(dotimes (_ ses--numrows)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(insert-and-inherit ses--blank-line))
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter (row ses--numrows) "Reprinting..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (eq (ses-cell-value row 0) '*skip*)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Column deletion left a dangling skip.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row 0 'value nil))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-print-cell row col))
|
|
|
|
|
(beginning-of-line 2))
|
|
|
|
|
(ses-jump-safe startcell)))
|
|
|
|
|
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(defun ses-initialize-Dijkstra-attempt ()
|
|
|
|
|
(setq ses--Dijkstra-attempt-nb (1+ ses--Dijkstra-attempt-nb)
|
|
|
|
|
ses--Dijkstra-weight-bound (* ses--numrows ses--numcols)))
|
|
|
|
|
|
2014-09-30 08:06:28 +00:00
|
|
|
|
;; These functions use the variables 'row' and 'col' that are dynamically bound
|
|
|
|
|
;; by ses-print-cell. We define these variables at compile-time to make the
|
|
|
|
|
;; compiler happy.
|
2014-09-30 17:52:11 +00:00
|
|
|
|
;; (defvar row)
|
|
|
|
|
;; (defvar col)
|
|
|
|
|
;; (defvar maxrow)
|
|
|
|
|
;; (defvar maxcol)
|
2014-09-30 08:06:28 +00:00
|
|
|
|
|
2017-04-03 03:09:53 +00:00
|
|
|
|
(defun ses-recalculate-cell (&optional curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Recalculate and reprint the current cell or range.
|
|
|
|
|
|
2017-04-03 03:09:53 +00:00
|
|
|
|
If CURCELL is non nil use it as current cell or range
|
2017-04-01 17:46:48 +00:00
|
|
|
|
without any check, otherwise function (ses-check-curcell 'range)
|
2017-03-20 21:42:00 +00:00
|
|
|
|
is called.
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
For an individual cell, shows the error if the formula or printer
|
|
|
|
|
signals one, or otherwise shows the cell's complete value. For a range, the
|
|
|
|
|
cells are recalculated in \"natural\" order, so cells that other cells refer
|
|
|
|
|
to are recalculated first."
|
|
|
|
|
(interactive "*")
|
2017-04-03 03:09:53 +00:00
|
|
|
|
(if curcell (setq ses--curcell curcell)
|
|
|
|
|
(ses-check-curcell 'range))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-begin-change)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-initialize-Dijkstra-attempt)
|
|
|
|
|
(let (sig cur-rowcol)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq ses-start-time (float-time))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (atom ses--curcell)
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(when
|
|
|
|
|
(setq cur-rowcol (ses-sym-rowcol ses--curcell)
|
|
|
|
|
sig (progn
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-cell-property :ses-Dijkstra-attempt
|
|
|
|
|
(car cur-rowcol)
|
|
|
|
|
(cdr cur-rowcol))
|
|
|
|
|
(cons ses--Dijkstra-attempt-nb 0))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(ses-calculate-cell (car cur-rowcol) (cdr cur-rowcol) t)))
|
|
|
|
|
(nconc sig (list (ses-cell-symbol (car cur-rowcol)
|
|
|
|
|
(cdr cur-rowcol)))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; First, recalculate all cells that don't refer to other cells and
|
|
|
|
|
;; produce a list of cells with references.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-dorange ses--curcell
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(ses--time-check "Recalculating... %s" (ses-cell-symbol row col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; The t causes an error if the cell has references. If no
|
|
|
|
|
;; references, the t will be the result value.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1value (ses-formula-references (ses-cell-formula row col) t))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-cell-property :ses-Dijkstra-attempt row col)
|
|
|
|
|
(cons ses--Dijkstra-attempt-nb 0))
|
2011-06-27 06:02:27 +00:00
|
|
|
|
(when (setq sig (ses-calculate-cell row col t))
|
|
|
|
|
(nconc sig (list (ses-cell-symbol row col)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(wrong-type-argument
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; The formula contains a reference.
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(cl-pushnew (ses-cell-symbol row col) ses--deferred-recalc
|
|
|
|
|
:test #'equal)))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Do the update now, so we can force recalculation.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((x ses--deferred-recalc))
|
|
|
|
|
(setq ses--deferred-recalc nil)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(condition-case hold
|
|
|
|
|
(ses-update-cells x t)
|
|
|
|
|
(error (setq sig hold))))
|
|
|
|
|
(cond
|
|
|
|
|
(sig
|
2005-09-18 12:25:02 +00:00
|
|
|
|
(message "%s" (error-message-string sig)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
((consp ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(message " "))
|
|
|
|
|
(t
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(princ (symbol-value ses--curcell))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-recalculate-all ()
|
|
|
|
|
"Recalculate and reprint all cells."
|
|
|
|
|
(interactive "*")
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let ((startcell (ses--cell-at-pos (point)))
|
2017-06-22 07:27:17 +00:00
|
|
|
|
(ses--curcell (cons (ses-cell-symbol 0 0)
|
|
|
|
|
(ses-cell-symbol (1- ses--numrows)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(1- ses--numcols)))))
|
2017-03-20 21:42:00 +00:00
|
|
|
|
(ses-recalculate-cell ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-jump-safe startcell)))
|
|
|
|
|
|
|
|
|
|
(defun ses-truncate-cell ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Reprint current cell, but without spillover into any following blank cells."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*")
|
|
|
|
|
(ses-check-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let* ((rowcol (ses-sym-rowcol ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(row (car rowcol))
|
|
|
|
|
(col (cdr rowcol)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when (and (< col (1- ses--numcols)) ;;Last column can't spill over, anyway
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(eq (ses-cell-value row (1+ col)) '*skip*))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; This cell has spill-over. We'll momentarily pretend the following cell
|
2015-05-21 17:04:45 +00:00
|
|
|
|
;; has a t in it.
|
2014-07-21 17:53:38 +00:00
|
|
|
|
(cl-progv
|
|
|
|
|
(list (ses-cell-symbol row (1+ col)))
|
|
|
|
|
'(t)
|
|
|
|
|
(ses-print-cell row col))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Now remove the *skip*. ses-print-cell is always nil here.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row (1+ col) 'value nil)
|
|
|
|
|
(1value (ses-print-cell row (1+ col))))))
|
|
|
|
|
|
|
|
|
|
(defun ses-reconstruct-all ()
|
|
|
|
|
"Reconstruct buffer based on cell data stored in Emacs variables."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
;;Reconstruct reference lists.
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(let (x yrow ycol)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Delete old reference lists
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(row ses--numrows) "Deleting references..."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row col 'references nil)))
|
|
|
|
|
;;Create new reference lists
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(row ses--numrows) "Computing references..."
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dolist (ref (ses-formula-references (ses-cell-formula row col)))
|
|
|
|
|
(setq x (ses-sym-rowcol ref)
|
|
|
|
|
yrow (car x)
|
|
|
|
|
ycol (cdr x))
|
|
|
|
|
(ses-set-cell yrow ycol 'references
|
|
|
|
|
(cons (ses-cell-symbol row col)
|
|
|
|
|
(ses-cell-references yrow ycol)))))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Delete everything and reconstruct basic data area.
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(ses-widen)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(goto-char (point-max))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(if (search-backward ";; Local Variables:\n" nil t)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(delete-region (point-min) (point))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Buffer is quite screwed up --- can't even save the user-specified
|
|
|
|
|
;; locals.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(delete-region (point-min) (point-max))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert ses-initial-file-trailer)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Create a blank display area.
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(dotimes (_ ses--numrows)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(insert ses--blank-line))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert ses-print-data-boundary)
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(backward-char (1- (length ses-print-data-boundary)))
|
|
|
|
|
(setq ses--data-marker (point-marker))
|
|
|
|
|
(forward-char (1- (length ses-print-data-boundary)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Placeholders for cell data.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(insert (make-string (* ses--numrows (1+ ses--numcols)) ?\n))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Placeholders for col-widths, col-printers, default-printer, header-row.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert "\n\n\n\n")
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(insert ses-initial-global-parameters)
|
|
|
|
|
(backward-char (1- (length ses-initial-global-parameters)))
|
|
|
|
|
(setq ses--params-marker (point-marker))
|
|
|
|
|
(forward-char (1- (length ses-initial-global-parameters))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--col-widths ses--col-widths)
|
|
|
|
|
(ses-set-parameter 'ses--col-printers ses--col-printers)
|
|
|
|
|
(ses-set-parameter 'ses--default-printer ses--default-printer)
|
|
|
|
|
(ses-set-parameter 'ses--header-row ses--header-row)
|
|
|
|
|
(ses-set-parameter 'ses--numrows ses--numrows)
|
|
|
|
|
(ses-set-parameter 'ses--numcols ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Keep our old narrowing
|
|
|
|
|
(ses-setup)
|
|
|
|
|
(ses-recalculate-all)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(goto-char (point-min)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Input of cell formulas
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(defun ses-edit-cell-complete-symbol ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((completion-at-point-functions (cons 'ses--edit-cell-completion-at-point-function
|
|
|
|
|
completion-at-point-functions)))
|
|
|
|
|
(completion-at-point)))
|
|
|
|
|
|
|
|
|
|
(defun ses--edit-cell-completion-at-point-function ()
|
|
|
|
|
(and
|
|
|
|
|
ses--completion-table
|
|
|
|
|
(let* ((bol (save-excursion (move-beginning-of-line nil) (point)))
|
|
|
|
|
start end collection
|
|
|
|
|
(prefix
|
|
|
|
|
(save-excursion
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(backward-sexp)
|
|
|
|
|
(if (< (point) bol)
|
|
|
|
|
(progn
|
|
|
|
|
(setq start bol)
|
|
|
|
|
(buffer-substring start end))
|
|
|
|
|
(setq start (point))
|
|
|
|
|
(forward-sexp)
|
|
|
|
|
(if (>= (point) end)
|
|
|
|
|
(progn
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(buffer-substring start end))
|
|
|
|
|
nil))))
|
|
|
|
|
prefix-length)
|
|
|
|
|
(when (and prefix (null (string= prefix "")))
|
|
|
|
|
(setq prefix-length (length prefix))
|
2018-03-02 01:28:03 +00:00
|
|
|
|
(maphash (lambda (key _val)
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(let ((key-name (symbol-name key)))
|
|
|
|
|
(when (and (>= (length key-name) prefix-length)
|
|
|
|
|
(string= prefix (substring key-name 0 prefix-length)))
|
|
|
|
|
(push key-name collection))))
|
|
|
|
|
ses--completion-table)
|
|
|
|
|
(and collection (list start end collection))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-edit-cell (row col newval)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Display current cell contents in minibuffer, for editing.
|
|
|
|
|
Return nil if cell formula was unsafe and user declined confirmation."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(progn
|
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(ses-check-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let* ((rowcol (ses-sym-rowcol ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(row (car rowcol))
|
|
|
|
|
(col (cdr rowcol))
|
|
|
|
|
(formula (ses-cell-formula row col))
|
|
|
|
|
initial)
|
|
|
|
|
(if (eq (car-safe formula) 'ses-safe-formula)
|
|
|
|
|
(setq formula (cadr formula)))
|
|
|
|
|
(if (eq (car-safe formula) 'quote)
|
|
|
|
|
(setq initial (format "'%S" (cadr formula)))
|
|
|
|
|
(setq initial (prin1-to-string formula)))
|
|
|
|
|
(if (stringp formula)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Position cursor inside close-quote.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq initial (cons initial (length initial))))
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(dolist (key ses-completion-keys)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(define-key ses-mode-edit-map key #'ses-edit-cell-complete-symbol))
|
2017-07-20 22:40:48 +00:00
|
|
|
|
;; make it globally visible, so that it can be visible from the minibuffer.
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(setq ses--completion-table ses--named-cell-hashmap)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(list row col
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(read-from-minibuffer (format "Cell %s: " ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
initial
|
|
|
|
|
ses-mode-edit-map
|
2011-06-27 05:41:58 +00:00
|
|
|
|
t ; Convert to Lisp object.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
'ses-read-cell-history)))))
|
|
|
|
|
(when (ses-warn-unsafe newval 'unsafep)
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
(ses-cell-set-formula row col newval)
|
|
|
|
|
t))
|
|
|
|
|
|
|
|
|
|
(defun ses-read-cell (row col newval)
|
|
|
|
|
"Self-insert for initial character of cell function."
|
|
|
|
|
(interactive
|
2006-01-23 22:04:36 +00:00
|
|
|
|
(let* ((initial (this-command-keys))
|
|
|
|
|
(rowcol (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell)))
|
|
|
|
|
(curval (ses-cell-formula (car rowcol) (cdr rowcol))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(list (car rowcol)
|
|
|
|
|
(cdr rowcol)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(if (equal initial "\"")
|
|
|
|
|
(progn
|
|
|
|
|
(if (not (stringp curval)) (setq curval nil))
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(read-string (format-prompt "String Cell %s"
|
|
|
|
|
curval ses--curcell)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
nil 'ses-read-string-history curval))
|
|
|
|
|
(read-from-minibuffer
|
|
|
|
|
(format "Cell %s: " ses--curcell)
|
|
|
|
|
(cons (if (equal initial "(") "()" initial) 2)
|
|
|
|
|
ses-mode-edit-map
|
|
|
|
|
t ; Convert to Lisp object.
|
|
|
|
|
'ses-read-cell-history
|
|
|
|
|
(prin1-to-string (if (eq (car-safe curval) 'ses-safe-formula)
|
|
|
|
|
(cadr curval)
|
|
|
|
|
curval)))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(when (ses-edit-cell row col newval)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-command-hook) ; Update cell widths before movement.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dolist (x ses-after-entry-functions)
|
|
|
|
|
(funcall x 1))))
|
|
|
|
|
|
|
|
|
|
(defun ses-read-symbol (row col symb)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"Self-insert for a symbol as a cell formula.
|
|
|
|
|
The set of all symbols that have been used as formulas in this
|
|
|
|
|
spreadsheet is available for completions."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((rowcol (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
newval)
|
|
|
|
|
(barf-if-buffer-read-only)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq newval (completing-read (format "Cell %s ': " ses--curcell)
|
|
|
|
|
ses--symbolic-formulas))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(list (car rowcol)
|
|
|
|
|
(cdr rowcol)
|
|
|
|
|
(if (string= newval "")
|
2011-06-27 05:41:58 +00:00
|
|
|
|
nil ; Don't create zero-length symbols!
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(list 'quote (intern newval))))))
|
|
|
|
|
(when (ses-edit-cell row col symb)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-command-hook) ; Update cell widths before movement.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dolist (x ses-after-entry-functions)
|
|
|
|
|
(funcall x 1))))
|
|
|
|
|
|
|
|
|
|
(defun ses-clear-cell-forward (count)
|
|
|
|
|
"Delete formula and printer for current cell and then move to next cell.
|
|
|
|
|
With prefix, deletes several cells."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(if (< count 0)
|
|
|
|
|
(1value (ses-clear-cell-backward (- count)))
|
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
(ses-begin-change)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(dotimes (_ count)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((rowcol (ses-sym-rowcol ses--curcell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or rowcol (signal 'end-of-buffer nil))
|
|
|
|
|
(ses-clear-cell (car rowcol) (cdr rowcol)))
|
|
|
|
|
(forward-char 1))))
|
|
|
|
|
|
|
|
|
|
(defun ses-clear-cell-backward (count)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Move to previous cell and then delete it. With prefix, delete several cells."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(if (< count 0)
|
|
|
|
|
(1value (ses-clear-cell-forward (- count)))
|
|
|
|
|
(ses-check-curcell 'end)
|
|
|
|
|
(ses-begin-change)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(dotimes (_ count)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(backward-char 1) ; Will signal 'beginning-of-buffer if appropriate.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((rowcol (ses-sym-rowcol ses--curcell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-clear-cell (car rowcol) (cdr rowcol))))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Input of cell-printer functions
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(defun ses-read-printer-complete-symbol ()
|
|
|
|
|
(interactive)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(let ((completion-at-point-functions
|
|
|
|
|
(cons #'ses--read-printer-completion-at-point-function
|
|
|
|
|
completion-at-point-functions)))
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(completion-at-point)))
|
|
|
|
|
|
|
|
|
|
(defun ses--read-printer-completion-at-point-function ()
|
|
|
|
|
(let* ((bol (save-excursion (move-beginning-of-line nil) (point)))
|
|
|
|
|
start end collection
|
|
|
|
|
(prefix
|
|
|
|
|
(save-excursion
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(backward-sexp)
|
|
|
|
|
(if (< (point) bol)
|
|
|
|
|
(progn
|
|
|
|
|
(setq start bol)
|
|
|
|
|
(buffer-substring start end))
|
|
|
|
|
(setq start (point))
|
|
|
|
|
(forward-sexp)
|
|
|
|
|
(if (>= (point) end)
|
|
|
|
|
(progn
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(buffer-substring start end))
|
|
|
|
|
nil))))
|
|
|
|
|
prefix-length)
|
|
|
|
|
(when prefix
|
|
|
|
|
(setq prefix-length (length prefix))
|
2018-03-02 01:28:03 +00:00
|
|
|
|
(maphash (lambda (key _val)
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(let ((key-name (symbol-name key)))
|
|
|
|
|
(when (and (>= (length key-name) prefix-length)
|
|
|
|
|
(string= prefix (substring key-name 0 prefix-length)))
|
|
|
|
|
(push key-name collection))))
|
|
|
|
|
ses--completion-table)
|
|
|
|
|
(and collection (list start end collection)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-read-printer (prompt default)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
"Common code for functions `ses-read-cell-printer', `ses-read-column-printer',
|
|
|
|
|
`ses-read-default-printer' and `ses-define-local-printer'.
|
|
|
|
|
PROMPT should end with \": \". Result is t if operation was
|
|
|
|
|
canceled."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(if (eq default t)
|
|
|
|
|
(setq default "")
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
(setq prompt (format-prompt prompt default)))
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(dolist (key ses-completion-keys)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
(define-key ses-mode-edit-map key #'ses-read-printer-complete-symbol))
|
2017-07-20 22:40:48 +00:00
|
|
|
|
;; make it globally visible, so that it can be visible from the minibuffer.
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(setq ses--completion-table ses--local-printer-hashmap)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((new (read-from-minibuffer prompt
|
2011-06-27 05:41:58 +00:00
|
|
|
|
nil ; Initial contents.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
ses-mode-edit-map
|
2011-06-27 05:41:58 +00:00
|
|
|
|
t ; Evaluate the result.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
'ses-read-printer-history
|
|
|
|
|
(prin1-to-string default))))
|
|
|
|
|
(if (equal new default)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; User changed mind, decided not to change printer.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq new t)
|
|
|
|
|
(ses-printer-validate new)
|
|
|
|
|
(or (not new)
|
|
|
|
|
(stringp new)
|
|
|
|
|
(stringp (car-safe new))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(and (symbolp new) (gethash new ses--local-printer-hashmap))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-warn-unsafe new 'unsafep-function)
|
|
|
|
|
(setq new t)))
|
|
|
|
|
new))
|
|
|
|
|
|
|
|
|
|
(defun ses-read-cell-printer (newval)
|
|
|
|
|
"Set the printer function for the current cell or range.
|
|
|
|
|
|
|
|
|
|
A printer function is either a string (a format control-string with one
|
|
|
|
|
%-sequence -- result from format will be right-justified), or a list of one
|
|
|
|
|
string (result from format will be left-justified), or a lambda-expression of
|
|
|
|
|
one argument, or a symbol that names a function of one argument. In the
|
|
|
|
|
latter two cases, the function's result should be either a string (will be
|
|
|
|
|
right-justified) or a list of one string (will be left-justified)."
|
|
|
|
|
(interactive
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let ((default t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell 'range)
|
|
|
|
|
;;Default is none if not all cells in range have same printer
|
|
|
|
|
(catch 'ses-read-cell-printer
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-dorange ses--curcell
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let ((x (ses-cell-printer row col)))
|
|
|
|
|
(if (eq (car-safe x) 'ses-safe-printer)
|
|
|
|
|
(setq x (cadr x)))
|
|
|
|
|
(if (eq default t)
|
|
|
|
|
(setq default x)
|
|
|
|
|
(unless (equal default x)
|
|
|
|
|
;;Range contains differing printer functions
|
|
|
|
|
(setq default t)
|
|
|
|
|
(throw 'ses-read-cell-printer t))))))
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
(list (ses-read-printer (format "Cell %S printer" ses--curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
default))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(unless (eq newval t)
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-dorange ses--curcell
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-set-cell row col 'printer newval)
|
|
|
|
|
(ses-print-cell row col))))
|
|
|
|
|
|
|
|
|
|
(defun ses-read-column-printer (col newval)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Set the printer function for the current column.
|
|
|
|
|
See `ses-read-cell-printer' for input forms."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((col (cdr (ses-sym-rowcol ses--curcell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell)
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
(list col (ses-read-printer (format "Column %s printer"
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-column-letter col))
|
|
|
|
|
(ses-col-printer col)))))
|
|
|
|
|
|
|
|
|
|
(unless (eq newval t)
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--col-printers newval col)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(save-excursion
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (row ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-print-cell row col)))))
|
|
|
|
|
|
|
|
|
|
(defun ses-read-default-printer (newval)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Set the default printer function for cells that have no other.
|
|
|
|
|
See `ses-read-cell-printer' for input forms."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
(list (ses-read-printer "Default printer" ses--default-printer)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(unless (eq newval t)
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--default-printer newval)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reprint-all t)))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Spreadsheet size adjustments
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-insert-row (count)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Insert a new row before the current one.
|
|
|
|
|
With prefix, insert COUNT rows before current one."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(ses-check-curcell 'end)
|
|
|
|
|
(or (> count 0) (signal 'args-out-of-range nil))
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
(let ((inhibit-quit t)
|
|
|
|
|
(inhibit-read-only t)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(row (or (car (ses-sym-rowcol ses--curcell)) ses--numrows))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
newrow)
|
|
|
|
|
;;Create a new set of cell-variables
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-create-cell-variable-range ses--numrows (+ ses--numrows count -1)
|
|
|
|
|
0 (1- ses--numcols))
|
|
|
|
|
(ses-set-parameter 'ses--numrows (+ ses--numrows count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Insert each row
|
|
|
|
|
(ses-goto-print row 0)
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter (x count) "Inserting row..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Create a row of empty cells. The `symbol' fields will be set by
|
|
|
|
|
;;the call to ses-relocate-all.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq newrow (make-vector ses--numcols nil))
|
|
|
|
|
(dotimes (col ses--numcols)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(aset newrow col (ses-make-cell)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--cells (ses-vector-insert ses--cells row newrow))
|
2005-01-31 22:47:40 +00:00
|
|
|
|
(push `(apply ses-vector-delete ses--cells ,row 1) buffer-undo-list)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(insert ses--blank-line))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Insert empty lines in cell data area (will be replaced by
|
|
|
|
|
;;ses-relocate-all)
|
|
|
|
|
(ses-goto-data row 0)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(insert (make-string (* (1+ ses--numcols) count) ?\n))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-relocate-all row 0 count 0)
|
|
|
|
|
;;If any cell printers insert constant text, insert that text
|
|
|
|
|
;;into the line.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((cols (mapconcat #'ses-call-printer ses--col-printers nil))
|
|
|
|
|
(global (ses-call-printer ses--default-printer)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (or (> (length cols) 0) (> (length global) 0))
|
|
|
|
|
(dotimes (x count)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;These cells are always nil, only constant formatting printed
|
|
|
|
|
(1value (ses-print-cell (+ x row) col))))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(when (> ses--header-row row)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Inserting before header
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--header-row (+ ses--header-row count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string)))
|
|
|
|
|
;;Reconstruct text attributes
|
|
|
|
|
(ses-setup)
|
2006-05-26 17:39:06 +00:00
|
|
|
|
;;Prepare for undo
|
|
|
|
|
(push '(apply ses-widen) buffer-undo-list)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Return to current cell
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if ses--curcell
|
|
|
|
|
(ses-jump-safe ses--curcell)
|
|
|
|
|
(ses-goto-print (1- ses--numrows) 0)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-delete-row (count)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Delete the current row.
|
|
|
|
|
With prefix, deletes COUNT rows starting from the current one."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
(or (> count 0) (signal 'args-out-of-range nil))
|
|
|
|
|
(let ((inhibit-quit t)
|
|
|
|
|
(inhibit-read-only t)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(row (car (ses-sym-rowcol ses--curcell))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq count (min count (- ses--numrows row)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--numrows (- ses--numrows count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Delete lines from print area
|
|
|
|
|
(ses-goto-print row 0)
|
|
|
|
|
(ses-delete-line count)
|
|
|
|
|
;;Delete lines from cell data area
|
|
|
|
|
(ses-goto-data row 0)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-delete-line (* count (1+ ses--numcols)))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; Collect named cells in the deleted rows, in order to clean the
|
|
|
|
|
;; symbols out of the named cell hash map, once the deletion is
|
|
|
|
|
;; complete
|
|
|
|
|
(unless (null ses--in-killing-named-cell-list)
|
|
|
|
|
(warn "Internal error, `ses--in-killing-named-cell-list' should be nil, but is equal to %S"
|
|
|
|
|
ses--in-killing-named-cell-list)
|
|
|
|
|
(setq ses--in-killing-named-cell-list nil))
|
|
|
|
|
(dotimes-with-progress-reporter (nrow count)
|
|
|
|
|
"Collecting named cell in deleted rows..."
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(let* ((row (+ row nrow))
|
|
|
|
|
(sym (ses-cell-symbol row col)))
|
|
|
|
|
(and (eq (get sym 'ses-cell) :ses-named)
|
|
|
|
|
(push sym ses--in-killing-named-cell-list)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Relocate variables and formulas
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-with-undo 'ses--cells (ses-vector-delete ses--cells row count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-relocate-all row 0 (- count) 0)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-destroy-cell-variable-range ses--numrows (+ ses--numrows count -1)
|
|
|
|
|
0 (1- ses--numcols))
|
|
|
|
|
(when (> ses--header-row row)
|
|
|
|
|
(if (<= ses--header-row (+ row count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Deleting the header row
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--header-row 0)
|
|
|
|
|
(ses-set-parameter 'ses--header-row (- ses--header-row count)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string)))
|
|
|
|
|
;;Reconstruct attributes
|
|
|
|
|
(ses-setup)
|
2006-05-26 17:39:06 +00:00
|
|
|
|
;;Prepare for undo
|
|
|
|
|
(push '(apply ses-widen) buffer-undo-list)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-jump-safe ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-insert-column (count &optional col width printer)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
"Insert a new column before COL (default is the current one).
|
|
|
|
|
With prefix, insert COUNT columns before current one.
|
|
|
|
|
If COL is specified, the new column(s) get the specified WIDTH and PRINTER
|
|
|
|
|
\(otherwise they're taken from the current column)."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
(or (> count 0) (signal 'args-out-of-range nil))
|
|
|
|
|
(or col
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq col (cdr (ses-sym-rowcol ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
width (ses-col-width col)
|
|
|
|
|
printer (ses-col-printer col)))
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
(let ((inhibit-quit t)
|
|
|
|
|
(inhibit-read-only t)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(widths ses--col-widths)
|
|
|
|
|
(printers ses--col-printers)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
has-skip)
|
|
|
|
|
;;Create a new set of cell-variables
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-create-cell-variable-range 0 (1- ses--numrows)
|
|
|
|
|
ses--numcols (+ ses--numcols count -1))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Insert each column.
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter (x count) "Inserting column..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Create a column of empty cells. The `symbol' fields will be set by
|
|
|
|
|
;;the call to ses-relocate-all.
|
|
|
|
|
(ses-adjust-print-width col (1+ width))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--numcols (1+ ses--numcols))
|
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(and (< (1+ col) ses--numcols) (eq (ses-cell-value row col) '*skip*)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Inserting in the middle of a spill-over
|
|
|
|
|
(setq has-skip t))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-aset-with-undo ses--cells row
|
|
|
|
|
(ses-vector-insert (aref ses--cells row)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
col (ses-make-cell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Insert empty lines in cell data area (will be replaced by
|
|
|
|
|
;;ses-relocate-all)
|
|
|
|
|
(ses-goto-data row col)
|
|
|
|
|
(insert ?\n))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Insert column width and printer.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq widths (ses-vector-insert widths col width)
|
|
|
|
|
printers (ses-vector-insert printers col printer)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--col-widths widths)
|
|
|
|
|
(ses-set-parameter 'ses--col-printers printers)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string)
|
|
|
|
|
(ses-relocate-all 0 col 0 count)
|
|
|
|
|
(if has-skip
|
|
|
|
|
(ses-reprint-all t)
|
|
|
|
|
(when (or (> (length (ses-call-printer printer)) 0)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(> (length (ses-call-printer ses--default-printer)) 0))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Either column printer or global printer inserts some constant text.
|
|
|
|
|
;; Reprint the new columns to insert that text.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(dotimes (x ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dotimes (y count)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Always nil here --- this is a blank column.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1value (ses-print-cell-new-width x (+ y col))))))
|
|
|
|
|
(ses-setup)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-jump-safe ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-delete-column (count)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Delete the current column.
|
|
|
|
|
With prefix, deletes COUNT columns starting from the current one."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
(or (> count 0) (signal 'args-out-of-range nil))
|
|
|
|
|
(let ((inhibit-quit t)
|
|
|
|
|
(inhibit-read-only t)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(rowcol (ses-sym-rowcol ses--curcell))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(width 0)
|
2004-11-22 01:21:07 +00:00
|
|
|
|
col origrow has-skip)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq origrow (car rowcol)
|
|
|
|
|
col (cdr rowcol)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
count (min count (- ses--numcols col)))
|
|
|
|
|
(if (= count ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Can't delete all columns!"))
|
|
|
|
|
;;Determine width of column(s) being deleted
|
|
|
|
|
(dotimes (x count)
|
|
|
|
|
(setq width (+ width (ses-col-width (+ col x)) 1)))
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--numcols (- ses--numcols count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-adjust-print-width col (- width))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; Prepare collecting named cells in the deleted columns, in order
|
|
|
|
|
;; to clean the symbols out of the named cell hash map, once the
|
|
|
|
|
;; deletion is complete
|
|
|
|
|
(unless (null ses--in-killing-named-cell-list)
|
|
|
|
|
(warn "Internal error, `ses--in-killing-named-cell-list' should be nil, but is equal to %S"
|
|
|
|
|
ses--in-killing-named-cell-list)
|
|
|
|
|
(setq ses--in-killing-named-cell-list nil))
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter (row ses--numrows) "Deleting column..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Delete lines from cell data area
|
|
|
|
|
(ses-goto-data row col)
|
|
|
|
|
(ses-delete-line count)
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
;; Collect named cells in the deleted columns within this row
|
|
|
|
|
(dotimes (ncol count)
|
|
|
|
|
(let ((sym (ses-cell-symbol row (+ col ncol))))
|
|
|
|
|
(and (eq (get sym 'ses-cell) :ses-named)
|
|
|
|
|
(push sym ses--in-killing-named-cell-list))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Delete cells. Check if deletion area begins or ends with a skip.
|
|
|
|
|
(if (or (eq (ses-cell-value row col) '*skip*)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(and (< col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(eq (ses-cell-value row (+ col count)) '*skip*)))
|
|
|
|
|
(setq has-skip t))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-aset-with-undo ses--cells row
|
|
|
|
|
(ses-vector-delete (aref ses--cells row) col count)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Update globals
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--col-widths
|
|
|
|
|
(ses-vector-delete ses--col-widths col count))
|
|
|
|
|
(ses-set-parameter 'ses--col-printers
|
|
|
|
|
(ses-vector-delete ses--col-printers col count))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string)
|
|
|
|
|
;;Relocate variables and formulas
|
|
|
|
|
(ses-relocate-all 0 col 0 (- count))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-destroy-cell-variable-range 0 (1- ses--numrows)
|
|
|
|
|
ses--numcols (+ ses--numcols count -1))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if has-skip
|
|
|
|
|
(ses-reprint-all t)
|
|
|
|
|
(ses-setup))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (>= col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq col (1- col)))
|
|
|
|
|
(ses-goto-print origrow col)))
|
|
|
|
|
|
|
|
|
|
(defun ses-forward-or-insert (&optional count)
|
|
|
|
|
"Move to next cell in row, or inserts a new cell if already in last one, or
|
|
|
|
|
inserts a new row if at bottom of print area. Repeat COUNT times."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(ses-check-curcell 'end)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(setq deactivate-mark t) ; Doesn't combine well with ranges.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(dotimes (x count)
|
|
|
|
|
(ses-set-curcell)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (not ses--curcell)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(progn ; At bottom of print area.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(ses-insert-row 1))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((col (cdr (ses-sym-rowcol ses--curcell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(when (/= 32
|
|
|
|
|
(char-before (next-single-property-change (point)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
'cursor-intangible)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; We're already in last nonskipped cell on line. Need to create a
|
|
|
|
|
;; new column.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(ses-insert-column (- count x)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
ses--numcols
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-col-width col)
|
|
|
|
|
(ses-col-printer col)))))
|
|
|
|
|
(forward-char)))
|
|
|
|
|
|
|
|
|
|
(defun ses-append-row-jump-first-column ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Insert a new row after current one and jump to its first column."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*")
|
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
(beginning-of-line 2)
|
|
|
|
|
(ses-set-curcell)
|
|
|
|
|
(ses-insert-row 1))
|
|
|
|
|
|
|
|
|
|
(defun ses-set-column-width (col newwidth)
|
|
|
|
|
"Set the width of the current column."
|
|
|
|
|
(interactive
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((col (cdr (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(list col
|
|
|
|
|
(if current-prefix-arg
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(read-from-minibuffer (format-prompt "Column %s width"
|
|
|
|
|
(ses-col-width col)
|
|
|
|
|
(ses-column-letter col))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
nil ; No initial contents.
|
|
|
|
|
nil ; No override keymap.
|
|
|
|
|
t ; Convert to Lisp object.
|
|
|
|
|
nil ; No history.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(number-to-string
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-col-width col))))))) ; Default value.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (< newwidth 1)
|
|
|
|
|
(error "Invalid column width"))
|
|
|
|
|
(ses-begin-change)
|
|
|
|
|
(ses-reset-header-string)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((inhibit-quit t))
|
|
|
|
|
(ses-adjust-print-width col (- newwidth (ses-col-width col)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-set-parameter 'ses--col-widths newwidth col))
|
|
|
|
|
(dotimes (row ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-print-cell-new-width row col))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Cut and paste, import and export
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(defun ses--advice-copy-region-as-kill (crak-fun beg end &rest args)
|
|
|
|
|
;; FIXME: Why doesn't it make sense to copy read-only or
|
|
|
|
|
;; intangible attributes? They're removed upon yank!
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"It doesn't make sense to copy read-only or intangible attributes into the
|
|
|
|
|
kill ring. It probably doesn't make sense to copy keymap properties.
|
|
|
|
|
We'll assume copying front-sticky properties doesn't make sense, either.
|
|
|
|
|
|
|
|
|
|
This advice also includes some SES-specific code because otherwise it's too
|
|
|
|
|
hard to override how mouse-1 works."
|
2017-12-16 00:34:35 +00:00
|
|
|
|
(when (and beg end (> beg end))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((temp beg))
|
|
|
|
|
(setq beg end
|
|
|
|
|
end temp)))
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(if (not (and (derived-mode-p 'ses-mode)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(eq (get-text-property beg 'read-only) 'ses)
|
|
|
|
|
(eq (get-text-property (1- end) 'read-only) 'ses)))
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(apply crak-fun beg end args) ; Normal copy-region-as-kill.
|
2005-01-02 01:20:14 +00:00
|
|
|
|
(kill-new (ses-copy-region beg end))
|
|
|
|
|
(if transient-mark-mode
|
|
|
|
|
(setq deactivate-mark t))
|
|
|
|
|
nil))
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(advice-add 'copy-region-as-kill :around #'ses--advice-copy-region-as-kill)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-copy-region (beg end)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Treat the region as rectangular.
|
|
|
|
|
Convert the intangible attributes to SES attributes recording the
|
|
|
|
|
contents of the cell as of the time of copying."
|
2007-10-25 20:12:26 +00:00
|
|
|
|
(when (= end ses--data-marker)
|
|
|
|
|
;;Avoid overflow situation
|
|
|
|
|
(setq end (1- ses--data-marker)))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(let* ((x (mapconcat #'ses-copy-region-helper
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(extract-rectangle beg (1- end)) "\n")))
|
|
|
|
|
(remove-text-properties 0 (length x)
|
|
|
|
|
'(read-only t
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
cursor-intangible t
|
2002-09-28 18:45:56 +00:00
|
|
|
|
keymap t
|
|
|
|
|
front-sticky t)
|
|
|
|
|
x)
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
(defun ses-copy-region-helper (line)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Convert one line (of a rectangle being extracted from a spreadsheet) to
|
2015-11-17 23:28:50 +00:00
|
|
|
|
external form by attaching to each print cell a `ses' attribute that records
|
2002-09-28 18:45:56 +00:00
|
|
|
|
the corresponding data cell."
|
|
|
|
|
(or (> (length line) 1)
|
|
|
|
|
(error "Empty range"))
|
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
|
(pos 0)
|
|
|
|
|
mycell next sym rowcol)
|
|
|
|
|
(while pos
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(setq sym (ses--cell-at-pos pos line)
|
|
|
|
|
next (next-single-property-change pos 'cursor-intangible line)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
rowcol (ses-sym-rowcol sym)
|
|
|
|
|
mycell (ses-get-cell (car rowcol) (cdr rowcol)))
|
|
|
|
|
(put-text-property pos (or next (length line))
|
|
|
|
|
'ses
|
|
|
|
|
(list (ses-cell-symbol mycell)
|
|
|
|
|
(ses-cell-formula mycell)
|
|
|
|
|
(ses-cell-printer mycell))
|
|
|
|
|
line)
|
|
|
|
|
(setq pos next)))
|
|
|
|
|
line)
|
|
|
|
|
|
|
|
|
|
(defun ses-kill-override (beg end)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Generic override for any commands that kill text.
|
|
|
|
|
We clear the killed cells instead of deleting them."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "r")
|
|
|
|
|
(ses-check-curcell 'needrange)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; For some reason, the text-read-only error is not caught by `delete-region',
|
|
|
|
|
;; so we have to use subterfuge.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((buffer-read-only t))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(1value (condition-case nil
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(noreturn (funcall (lookup-key (current-global-map)
|
|
|
|
|
(this-command-keys))
|
|
|
|
|
beg end))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(buffer-read-only nil)))) ; The expected error.
|
|
|
|
|
;; Because the buffer was marked read-only, the kill command turned itself
|
|
|
|
|
;; into a copy. Now we clear the cells or signal the error. First we check
|
|
|
|
|
;; whether the buffer really is read-only.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-dorange ses--curcell
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-clear-cell row col))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-jump (car ses--curcell)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(defun ses--advice-yank (yank-fun &optional arg &rest args)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"In SES mode, the yanked text is inserted as cells.
|
|
|
|
|
|
2015-11-17 23:28:50 +00:00
|
|
|
|
If the text contains `ses' attributes (meaning it went to the kill-ring from a
|
2002-09-28 18:45:56 +00:00
|
|
|
|
SES buffer), the formulas and print functions are restored for the cells. If
|
|
|
|
|
the text contains tabs, this is an insertion of tab-separated formulas.
|
|
|
|
|
Otherwise the text is inserted as the formula for the current cell.
|
|
|
|
|
|
|
|
|
|
When inserting cells, the formulas are usually relocated to keep the same
|
|
|
|
|
relative references to neighboring cells. This is best if the formulas
|
Docfix: use command substitution for 'universal-argument'
* lisp/autoarg.el (autoarg-mode):
* lisp/bookmark.el (bookmark-set, bookmark-set-no-overwrite)
(bookmark-save):
* lisp/calendar/todo-mode.el (todo-insert-item)
(todo-filter-top-priorities)
(todo-filter-top-priorities-multifile):
* lisp/dired-x.el (dired-mark-extension, dired-mark-suffix):
* lisp/eshell/eshell.el (eshell):
* lisp/gnus/gnus-group.el (gnus-group-find-new-groups):
* lisp/gnus/gnus-start.el (gnus-find-new-newsgroups):
* lisp/gnus/gnus-sum.el (gnus-summary-show-article):
* lisp/gnus/gnus.el (gnus-secondary-servers):
* lisp/org/org-timer.el (org-timer-set-timer):
* lisp/org/ox.el (org-export-dispatch-last-position):
* lisp/printing.el (pr-ps-directory-preview)
(pr-ps-directory-using-ghostscript, pr-ps-directory-print)
(pr-ps-directory-ps-print, pr-ps-buffer-preview)
(pr-ps-buffer-using-ghostscript, pr-ps-buffer-print)
(pr-ps-buffer-ps-print, pr-despool-preview)
(pr-despool-using-ghostscript, pr-despool-print)
(pr-despool-ps-print, pr-ps-file-up-ps-print, pr-ps-fast-fire)
(pr-txt-fast-fire):
* lisp/progmodes/idlwave.el (idlwave-complete):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/replace.el (occur):
* lisp/ses.el (ses--advice-yank):
* lisp/simple.el (set-mark-command-repeat-pop):
* lisp/sort.el (delete-duplicate-lines):
* lisp/strokes.el (strokes-help):
* lisp/textmodes/artist.el (artist-mode):
* lisp/textmodes/reftex-cite.el (reftex-citation):
* lisp/textmodes/reftex-dcr.el (reftex-view-crossref):
* lisp/textmodes/reftex-index.el (reftex-index-selection-or-word)
(reftex-display-index):
* lisp/textmodes/reftex-ref.el (reftex-reference):
* lisp/textmodes/reftex-toc.el (reftex-toc):
* lisp/textmodes/reftex-vars.el (reftex-cite-prompt-optional-args)
(reftex-enable-partial-scans):
* lisp/textmodes/texnfo-upd.el (texinfo-master-menu):
* lisp/windmove.el (windmove-display-in-direction)
(windmove-delete-left, windmove-delete-up)
(windmove-delete-right, windmove-delete-down):
* lisp/window.el (recenter-window-group, recenter-other-window): Use
command substitution for 'universal-argument' instead of raw "C-u".
2021-09-16 18:05:48 +00:00
|
|
|
|
generally refer to other cells within the yanked text. You can use the \\[universal-argument]
|
2002-09-28 18:45:56 +00:00
|
|
|
|
prefix to specify insertion without relocation, which is best when the
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
formulas refer to cells outside the yanked text.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
When inserting formulas, the text is treated as a string constant if it doesn't
|
2015-11-17 23:28:50 +00:00
|
|
|
|
make sense as a sexp or would otherwise be considered a symbol. Use `sym' to
|
Docfix: use command substitution for 'universal-argument'
* lisp/autoarg.el (autoarg-mode):
* lisp/bookmark.el (bookmark-set, bookmark-set-no-overwrite)
(bookmark-save):
* lisp/calendar/todo-mode.el (todo-insert-item)
(todo-filter-top-priorities)
(todo-filter-top-priorities-multifile):
* lisp/dired-x.el (dired-mark-extension, dired-mark-suffix):
* lisp/eshell/eshell.el (eshell):
* lisp/gnus/gnus-group.el (gnus-group-find-new-groups):
* lisp/gnus/gnus-start.el (gnus-find-new-newsgroups):
* lisp/gnus/gnus-sum.el (gnus-summary-show-article):
* lisp/gnus/gnus.el (gnus-secondary-servers):
* lisp/org/org-timer.el (org-timer-set-timer):
* lisp/org/ox.el (org-export-dispatch-last-position):
* lisp/printing.el (pr-ps-directory-preview)
(pr-ps-directory-using-ghostscript, pr-ps-directory-print)
(pr-ps-directory-ps-print, pr-ps-buffer-preview)
(pr-ps-buffer-using-ghostscript, pr-ps-buffer-print)
(pr-ps-buffer-ps-print, pr-despool-preview)
(pr-despool-using-ghostscript, pr-despool-print)
(pr-despool-ps-print, pr-ps-file-up-ps-print, pr-ps-fast-fire)
(pr-txt-fast-fire):
* lisp/progmodes/idlwave.el (idlwave-complete):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/replace.el (occur):
* lisp/ses.el (ses--advice-yank):
* lisp/simple.el (set-mark-command-repeat-pop):
* lisp/sort.el (delete-duplicate-lines):
* lisp/strokes.el (strokes-help):
* lisp/textmodes/artist.el (artist-mode):
* lisp/textmodes/reftex-cite.el (reftex-citation):
* lisp/textmodes/reftex-dcr.el (reftex-view-crossref):
* lisp/textmodes/reftex-index.el (reftex-index-selection-or-word)
(reftex-display-index):
* lisp/textmodes/reftex-ref.el (reftex-reference):
* lisp/textmodes/reftex-toc.el (reftex-toc):
* lisp/textmodes/reftex-vars.el (reftex-cite-prompt-optional-args)
(reftex-enable-partial-scans):
* lisp/textmodes/texnfo-upd.el (texinfo-master-menu):
* lisp/windmove.el (windmove-display-in-direction)
(windmove-delete-left, windmove-delete-up)
(windmove-delete-right, windmove-delete-down):
* lisp/window.el (recenter-window-group, recenter-other-window): Use
command substitution for 'universal-argument' instead of raw "C-u".
2021-09-16 18:05:48 +00:00
|
|
|
|
explicitly insert a symbol, or use the \\[universal-argument] prefix to treat all unmarked words
|
2002-09-28 18:45:56 +00:00
|
|
|
|
as symbols."
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(if (not (and (derived-mode-p 'ses-mode)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(eq (get-text-property (point) 'keymap) 'ses-mode-print-map)))
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(apply yank-fun arg args) ; Normal non-SES yank.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell 'end)
|
2017-04-28 08:25:26 +00:00
|
|
|
|
(push-mark)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((text (current-kill (cond
|
|
|
|
|
((listp arg) 0)
|
|
|
|
|
((eq arg '-) -1)
|
|
|
|
|
(t (1- arg))))))
|
|
|
|
|
(or (ses-yank-cells text arg)
|
|
|
|
|
(ses-yank-tsf text arg)
|
|
|
|
|
(ses-yank-one (ses-yank-resize 1 1)
|
|
|
|
|
text
|
|
|
|
|
0
|
|
|
|
|
(if (memq (aref text (1- (length text))) '(?\t ?\n))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Just one cell --- delete final tab or newline.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(1- (length text)))
|
|
|
|
|
arg)))
|
|
|
|
|
(if (consp arg)
|
|
|
|
|
(exchange-point-and-mark))))
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(advice-add 'yank :around #'ses--advice-yank)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-yank-pop (arg)
|
|
|
|
|
"Replace just-yanked stretch of killed text with a different stretch.
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
This command is allowed only immediately after a `yank' or a `yank-pop',
|
|
|
|
|
when the region contains a stretch of reinserted previously-killed text.
|
|
|
|
|
We replace it with a different stretch of killed text.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
Unlike standard `yank-pop', this function uses `undo' to delete the
|
|
|
|
|
previous insertion."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(or (eq last-command 'yank)
|
|
|
|
|
;;Use noreturn here just to avoid a "poor-coverage" warning in its
|
|
|
|
|
;;macro definition.
|
|
|
|
|
(noreturn (error "Previous command was not a yank")))
|
|
|
|
|
(undo)
|
|
|
|
|
(ses-set-curcell)
|
|
|
|
|
(yank (1+ (or arg 1)))
|
|
|
|
|
(setq this-command 'yank))
|
|
|
|
|
|
|
|
|
|
(defun ses-yank-cells (text arg)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"If TEXT has a proper set of `ses' attributes, insert it as cells.
|
|
|
|
|
Otherwise, return nil. The cells are reprinted--the supplied text is
|
2002-09-28 18:45:56 +00:00
|
|
|
|
ignored because the column widths, default printer, etc. at yank time might
|
|
|
|
|
be different from those at kill-time. ARG is a list to indicate that
|
|
|
|
|
formulas are to be inserted without relocation."
|
|
|
|
|
(let ((first (get-text-property 0 'ses text))
|
|
|
|
|
(last (get-text-property (1- (length text)) 'ses text)))
|
|
|
|
|
(when (and first last) ;;Otherwise not proper set of attributes
|
|
|
|
|
(setq first (ses-sym-rowcol (car first))
|
|
|
|
|
last (ses-sym-rowcol (car last)))
|
|
|
|
|
(let* ((needrows (- (car last) (car first) -1))
|
|
|
|
|
(needcols (- (cdr last) (cdr first) -1))
|
|
|
|
|
(rowcol (ses-yank-resize needrows needcols))
|
|
|
|
|
(rowincr (- (car rowcol) (car first)))
|
|
|
|
|
(colincr (- (cdr rowcol) (cdr first)))
|
|
|
|
|
(pos 0)
|
|
|
|
|
myrow mycol x)
|
2005-01-19 23:46:31 +00:00
|
|
|
|
(dotimes-with-progress-reporter (row needrows) "Yanking..."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq myrow (+ row (car rowcol)))
|
|
|
|
|
(dotimes (col needcols)
|
|
|
|
|
(setq mycol (+ col (cdr rowcol))
|
|
|
|
|
last (get-text-property pos 'ses text)
|
|
|
|
|
pos (next-single-property-change pos 'ses text)
|
|
|
|
|
x (ses-sym-rowcol (car last)))
|
|
|
|
|
(if (not last)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Newline --- all remaining cells on row are skipped.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq x (cons (- myrow rowincr) (+ needcols colincr -1))
|
|
|
|
|
last (list nil nil nil)
|
|
|
|
|
pos (1- pos)))
|
|
|
|
|
(if (/= (car x) (- myrow rowincr))
|
|
|
|
|
(error "Cell row error"))
|
|
|
|
|
(if (< (- mycol colincr) (cdr x))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Some columns were skipped.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((oldcol mycol))
|
|
|
|
|
(while (< (- mycol colincr) (cdr x))
|
|
|
|
|
(ses-clear-cell myrow mycol)
|
|
|
|
|
(setq col (1+ col)
|
|
|
|
|
mycol (1+ mycol)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-print-cell myrow (1- oldcol)))) ;; This inserts *skip*.
|
|
|
|
|
(when (car last) ; Skip this for *skip* cells.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq x (nth 2 last))
|
|
|
|
|
(unless (equal x (ses-cell-printer myrow mycol))
|
|
|
|
|
(or (not x)
|
|
|
|
|
(stringp x)
|
|
|
|
|
(eq (car-safe x) 'ses-safe-printer)
|
|
|
|
|
(setq x `(ses-safe-printer ,x)))
|
|
|
|
|
(ses-set-cell myrow mycol 'printer x))
|
|
|
|
|
(setq x (cadr last))
|
|
|
|
|
(if (atom arg)
|
|
|
|
|
(setq x (ses-relocate-formula x 0 0 rowincr colincr)))
|
|
|
|
|
(or (atom x)
|
|
|
|
|
(eq (car-safe x) 'ses-safe-formula)
|
|
|
|
|
(setq x `(ses-safe-formula ,x)))
|
|
|
|
|
(ses-cell-set-formula myrow mycol x)))
|
|
|
|
|
(when pos
|
|
|
|
|
(if (get-text-property pos 'ses text)
|
|
|
|
|
(error "Missing newline between rows"))
|
|
|
|
|
(setq pos (next-single-property-change pos 'ses text))))
|
|
|
|
|
t))))
|
|
|
|
|
|
|
|
|
|
(defun ses-yank-one (rowcol text from to arg)
|
|
|
|
|
"Insert the substring [FROM,TO] of TEXT as the formula for cell ROWCOL (a
|
|
|
|
|
cons of ROW and COL). Treat plain symbols as strings unless ARG is a list."
|
|
|
|
|
(let ((val (condition-case nil
|
|
|
|
|
(read-from-string text from to)
|
|
|
|
|
(error (cons nil from)))))
|
|
|
|
|
(cond
|
|
|
|
|
((< (cdr val) (or to (length text)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Invalid sexp --- leave it as a string.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq val (substring text from to)))
|
|
|
|
|
((and (car val) (symbolp (car val)))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setq val (if (consp arg)
|
|
|
|
|
(list 'quote (car val)) ; Keep symbol.
|
|
|
|
|
(substring text from to)))) ; Treat symbol as text.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(t
|
|
|
|
|
(setq val (car val))))
|
|
|
|
|
(let ((row (car rowcol))
|
|
|
|
|
(col (cdr rowcol)))
|
|
|
|
|
(or (atom val)
|
|
|
|
|
(setq val `(ses-safe-formula ,val)))
|
|
|
|
|
(ses-cell-set-formula row col val))))
|
|
|
|
|
|
|
|
|
|
(defun ses-yank-tsf (text arg)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"If TEXT contains tabs and/or newlines, treat the tabs as
|
|
|
|
|
column-separators and the newlines as row-separators and insert the text as
|
2002-09-28 18:45:56 +00:00
|
|
|
|
cell formulas--else return nil. Treat plain symbols as strings unless ARG
|
|
|
|
|
is a list. Ignore a final newline."
|
|
|
|
|
(if (or (not (string-match "[\t\n]" text))
|
|
|
|
|
(= (match-end 0) (length text)))
|
|
|
|
|
;;Not TSF format
|
|
|
|
|
nil
|
|
|
|
|
(if (/= (aref text (1- (length text))) ?\n)
|
|
|
|
|
(setq text (concat text "\n")))
|
|
|
|
|
(let ((pos -1)
|
|
|
|
|
(spots (list -1))
|
|
|
|
|
(cols 0)
|
|
|
|
|
(needrows 0)
|
|
|
|
|
needcols rowcol)
|
|
|
|
|
;;Find all the tabs and newlines
|
|
|
|
|
(while (setq pos (string-match "[\t\n]" text (1+ pos)))
|
|
|
|
|
(push pos spots)
|
|
|
|
|
(setq cols (1+ cols))
|
|
|
|
|
(when (eq (aref text pos) ?\n)
|
|
|
|
|
(if (not needcols)
|
|
|
|
|
(setq needcols cols)
|
|
|
|
|
(or (= needcols cols)
|
|
|
|
|
(error "Inconsistent row lengths")))
|
|
|
|
|
(setq cols 0
|
|
|
|
|
needrows (1+ needrows))))
|
|
|
|
|
;;Insert the formulas
|
|
|
|
|
(setq rowcol (ses-yank-resize needrows needcols))
|
|
|
|
|
(dotimes (row needrows)
|
|
|
|
|
(dotimes (col needcols)
|
|
|
|
|
(ses-yank-one (cons (+ (car rowcol) needrows (- row) -1)
|
|
|
|
|
(+ (cdr rowcol) needcols (- col) -1))
|
|
|
|
|
text (1+ (cadr spots)) (car spots) arg)
|
|
|
|
|
(setq spots (cdr spots))))
|
|
|
|
|
(ses-goto-print (+ (car rowcol) needrows -1)
|
|
|
|
|
(+ (cdr rowcol) needcols -1))
|
|
|
|
|
t)))
|
|
|
|
|
|
|
|
|
|
(defun ses-yank-resize (needrows needcols)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"If this yank will require inserting rows and/or columns, ask for
|
|
|
|
|
confirmation and then insert them. Result is (row,col) for top left of yank
|
2002-09-28 18:45:56 +00:00
|
|
|
|
spot, or error signal if user requests cancel."
|
|
|
|
|
(ses-begin-change)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((rowcol (if ses--curcell
|
|
|
|
|
(ses-sym-rowcol ses--curcell)
|
|
|
|
|
(cons ses--numrows 0)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
rowbool colbool)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq needrows (- (+ (car rowcol) needrows) ses--numrows)
|
|
|
|
|
needcols (- (+ (cdr rowcol) needcols) ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
rowbool (> needrows 0)
|
|
|
|
|
colbool (> needcols 0))
|
|
|
|
|
(when (or rowbool colbool)
|
|
|
|
|
;;Need to insert. Get confirm
|
2005-09-25 Romain Francoise <romain@orebokech.com>
* dired-aux.el (dired-copy-file-recursive):
* dired.el (dired-delete-file):
* ediff-mult.el (ediff-dir-diff-copy-file):
* ediff-util.el (ediff-test-save-region):
* forms.el (forms-mode):
* ido.el (ido-file-internal, ido-delete-file-at-head):
* log-edit.el (log-edit-done):
* ses.el (ses-yank-resize):
* play/gomoku.el (gomoku-human-plays, gomoku)
(gomoku-human-resigns, gomoku-prompt-for-other-game)
(gomoku-offer-a-draw):
* play/landmark.el (lm-human-resigns, lm):
* net/eudcb-ldap.el (eudc-ldap-check-base):
* play/mpuz.el (mpuz-offer-abort, mpuz-try-letter, mpuz-close-game):
* progmodes/ebrowse.el (ebrowse-find-pattern):
* progmodes/idlw-shell.el (idlwave-shell-set-bp-check):
* textmodes/reftex-index.el (reftex-index-initialize-phrases-buffer):
End `yes-or-no-p' and `y-or-n-p' prompts with question mark and
space.
* vc.el (vc-delete-file):
* play/gomoku.el (gomoku-terminate-game, gomoku)
(gomoku-prompt-for-move, gomoku-human-takes-back):
* play/landmark.el (lm-human-takes-back, lm-prompt-for-move)
(lm-start-robot, lm-human-plays): Remove extraneous spaces in
messages.
2005-09-24 23:26:28 +00:00
|
|
|
|
(or (y-or-n-p (format "Yank will insert %s%s%s. Continue? "
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if rowbool (format "%d rows" needrows) "")
|
|
|
|
|
(if (and rowbool colbool) " and " "")
|
|
|
|
|
(if colbool (format "%d columns" needcols) "")))
|
2014-01-06 06:25:30 +00:00
|
|
|
|
(error "Canceled"))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(when rowbool
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let (ses--curcell)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(save-excursion
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-goto-print ses--numrows 0)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-insert-row needrows))))
|
|
|
|
|
(when colbool
|
|
|
|
|
(ses-insert-column needcols
|
2004-02-14 23:56:51 +00:00
|
|
|
|
ses--numcols
|
|
|
|
|
(ses-col-width (1- ses--numcols))
|
|
|
|
|
(ses-col-printer (1- ses--numcols)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
rowcol))
|
|
|
|
|
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(defun ses-export-tsv (_beg _end)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Export values from the current range, with tabs between columns and
|
|
|
|
|
newlines between rows. Result is placed in kill ring."
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(ses-export-tab nil))
|
|
|
|
|
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(defun ses-export-tsf (_beg _end)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Export formulas from the current range, with tabs between columns and
|
|
|
|
|
newlines between rows. Result is placed in kill ring."
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(ses-export-tab t))
|
|
|
|
|
|
|
|
|
|
(defun ses-export-tab (want-formulas)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Export the current range with tabs between columns and newlines between rows.
|
|
|
|
|
Result is placed in kill ring. The export is values unless WANT-FORMULAS
|
|
|
|
|
is non-nil. Newlines and tabs in the export text are escaped."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell 'needrange)
|
|
|
|
|
(let ((print-escape-newlines t)
|
|
|
|
|
result item)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-dorange ses--curcell
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq item (if want-formulas
|
|
|
|
|
(ses-cell-formula row col)
|
|
|
|
|
(ses-cell-value row col)))
|
|
|
|
|
(if (eq (car-safe item) 'ses-safe-formula)
|
|
|
|
|
;;Hide our deferred safety-check marker
|
|
|
|
|
(setq item (cadr item)))
|
|
|
|
|
(if (or (not item) (eq item '*skip*))
|
|
|
|
|
(setq item ""))
|
|
|
|
|
(when (eq (car-safe item) 'quote)
|
|
|
|
|
(push "'" result)
|
|
|
|
|
(setq item (cadr item)))
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(setq item (ses-prin1 item))
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 16:58:46 +00:00
|
|
|
|
(setq item (string-replace "\t" "\\t" item))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push item result)
|
|
|
|
|
(cond
|
|
|
|
|
((< col maxcol)
|
|
|
|
|
(push "\t" result))
|
|
|
|
|
((< row maxrow)
|
|
|
|
|
(push "\n" result))))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq result (apply #'concat (nreverse result)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(kill-new result)))
|
|
|
|
|
|
2017-07-17 17:58:12 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Interactive help on symbols
|
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(defun ses-list-local-printers (&optional local-printer-hashmap)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"List local printers in a help buffer.
|
|
|
|
|
Can be called either during editing a printer or a formula, or
|
|
|
|
|
while in the SES buffer."
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (cond
|
|
|
|
|
((derived-mode-p 'ses-mode) ses--local-printer-hashmap)
|
|
|
|
|
((minibufferp) ses--completion-table)
|
|
|
|
|
((derived-mode-p 'help-mode) nil)
|
2021-05-05 13:05:50 +00:00
|
|
|
|
(t (user-error "Not in a SES buffer")))))
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(when local-printer-hashmap
|
|
|
|
|
(let ((ses--list-orig-buffer (or ses--list-orig-buffer (current-buffer))))
|
|
|
|
|
(help-setup-xref
|
|
|
|
|
(list (lambda (local-printer-hashmap buffer)
|
|
|
|
|
(let ((ses--list-orig-buffer
|
|
|
|
|
(if (buffer-live-p buffer) buffer)))
|
|
|
|
|
(ses-list-local-printers local-printer-hashmap)))
|
|
|
|
|
local-printer-hashmap ses--list-orig-buffer)
|
|
|
|
|
(called-interactively-p 'interactive))
|
|
|
|
|
|
|
|
|
|
(save-excursion
|
|
|
|
|
(with-help-window (help-buffer)
|
|
|
|
|
(if (= 0 (hash-table-count local-printer-hashmap))
|
|
|
|
|
(princ "No local printers defined.")
|
|
|
|
|
(princ "List of local printers definitions:\n")
|
|
|
|
|
(maphash (lambda (key val)
|
|
|
|
|
(princ key)
|
|
|
|
|
(princ " as ")
|
|
|
|
|
(prin1 (ses--locprn-def val))
|
|
|
|
|
(princ "\n"))
|
|
|
|
|
local-printer-hashmap))
|
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
|
(buffer-string)))))))
|
|
|
|
|
|
|
|
|
|
(defun ses-list-named-cells (&optional named-cell-hashmap)
|
2021-04-25 11:12:48 +00:00
|
|
|
|
"List named cells in a help buffer.
|
|
|
|
|
Can be called either during editing a printer or a formula, or
|
|
|
|
|
while in the SES buffer."
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (cond
|
|
|
|
|
((derived-mode-p 'ses-mode) ses--named-cell-hashmap)
|
|
|
|
|
((minibufferp) ses--completion-table)
|
|
|
|
|
((derived-mode-p 'help-mode) nil)
|
2021-05-05 13:05:50 +00:00
|
|
|
|
(t (user-error "Not in a SES buffer")))))
|
2017-07-17 17:58:12 +00:00
|
|
|
|
(when named-cell-hashmap
|
|
|
|
|
(let ((ses--list-orig-buffer (or ses--list-orig-buffer (current-buffer))))
|
|
|
|
|
(help-setup-xref
|
|
|
|
|
(list (lambda (named-cell-hashmap buffer)
|
|
|
|
|
(let ((ses--list-orig-buffer
|
|
|
|
|
(if (buffer-live-p buffer) buffer)))
|
|
|
|
|
(ses-list-named-cells named-cell-hashmap)))
|
|
|
|
|
named-cell-hashmap ses--list-orig-buffer)
|
|
|
|
|
(called-interactively-p 'interactive))
|
|
|
|
|
|
|
|
|
|
(save-excursion
|
|
|
|
|
(with-help-window (help-buffer)
|
|
|
|
|
(if (= 0 (hash-table-count named-cell-hashmap))
|
|
|
|
|
(princ "No cell was renamed.")
|
|
|
|
|
(princ "List of named cells definitions:\n")
|
|
|
|
|
(maphash (lambda (key val)
|
|
|
|
|
(princ key)
|
|
|
|
|
(princ " for ")
|
|
|
|
|
(prin1 (ses-create-cell-symbol (car val) (cdr val)))
|
|
|
|
|
(princ "\n"))
|
|
|
|
|
named-cell-hashmap))
|
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
|
(buffer-string)))))))
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Other user commands
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(defun ses-unset-header-row ()
|
|
|
|
|
"Select the default header row."
|
|
|
|
|
(interactive)
|
|
|
|
|
(ses-set-header-row 0))
|
|
|
|
|
|
|
|
|
|
(defun ses-set-header-row (row)
|
|
|
|
|
"Set the ROW to display in the header-line.
|
|
|
|
|
With a numerical prefix arg, use that row.
|
|
|
|
|
With no prefix arg, use the current row.
|
|
|
|
|
With a \\[universal-argument] prefix arg, prompt the user.
|
|
|
|
|
The top row is row 1. Selecting row 0 displays the default header row."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (if (numberp current-prefix-arg) current-prefix-arg
|
2021-05-05 13:05:50 +00:00
|
|
|
|
(let* ((curcell (or (ses--cell-at-pos (point))
|
|
|
|
|
(user-error "Invalid header-row")))
|
|
|
|
|
(currow (1+ (car (ses-sym-rowcol curcell)))))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if current-prefix-arg
|
2004-03-26 14:50:41 +00:00
|
|
|
|
(read-number "Header row: " currow)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
currow)))))
|
|
|
|
|
(if (or (< row 0) (> row ses--numrows))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Invalid header-row"))
|
|
|
|
|
(ses-begin-change)
|
2006-05-26 17:39:06 +00:00
|
|
|
|
(let ((oldval ses--header-row))
|
|
|
|
|
(let (buffer-undo-list)
|
|
|
|
|
(ses-set-parameter 'ses--header-row row))
|
|
|
|
|
(push `(apply ses-set-header-row ,oldval) buffer-undo-list))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-reset-header-string))
|
|
|
|
|
|
|
|
|
|
(defun ses-mark-row ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Mark the entirety of current row as a range."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(ses-check-curcell 'range)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((row (car (ses-sym-rowcol (or (car-safe ses--curcell) ses--curcell)))))
|
2017-04-28 08:25:26 +00:00
|
|
|
|
(push-mark)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-goto-print (1+ row) 0)
|
|
|
|
|
(push-mark (point) nil t)
|
|
|
|
|
(ses-goto-print row 0)))
|
|
|
|
|
|
|
|
|
|
(defun ses-mark-column ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Mark the entirety of current column as a range."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(ses-check-curcell 'range)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((col (cdr (ses-sym-rowcol (or (car-safe ses--curcell) ses--curcell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(row 0))
|
2017-04-28 08:25:26 +00:00
|
|
|
|
(push-mark)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(ses-goto-print (1- ses--numrows) col)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(forward-char 1)
|
|
|
|
|
(push-mark (point) nil t)
|
|
|
|
|
(while (eq '*skip* (ses-cell-value row col))
|
|
|
|
|
;;Skip over initial cells in column that can't be selected
|
|
|
|
|
(setq row (1+ row)))
|
|
|
|
|
(ses-goto-print row col)))
|
|
|
|
|
|
|
|
|
|
(defun ses-end-of-line ()
|
|
|
|
|
"Move point to last cell on line."
|
|
|
|
|
(interactive)
|
|
|
|
|
(ses-check-curcell 'end 'range)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(when ses--curcell ; Otherwise we're at the bottom row, which is empty
|
|
|
|
|
; anyway.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((col (1- ses--numcols))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
row rowcol)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (symbolp ses--curcell)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Single cell.
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq row (car (ses-sym-rowcol ses--curcell)))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Range --- use whichever end of the range the point is at.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq rowcol (ses-sym-rowcol (if (< (point) (mark))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(car ses--curcell)
|
|
|
|
|
(cdr ses--curcell))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; If range already includes the last cell in a row, point is actually
|
|
|
|
|
;; in the following row.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (<= (cdr rowcol) (1- col))
|
|
|
|
|
(setq row (car rowcol))
|
|
|
|
|
(setq row (1+ (car rowcol)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (= row ses--numrows)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Already at end - can't go anywhere
|
|
|
|
|
(setq col 0))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(when (< row ses--numrows) ; Otherwise it's a range that includes last cell.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(while (eq (ses-cell-value row col) '*skip*)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Back to beginning of multi-column cell.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq col (1- col)))
|
|
|
|
|
(ses-goto-print row col)))))
|
|
|
|
|
|
|
|
|
|
(defun ses-renarrow-buffer ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Narrow the buffer so only the print area is visible.
|
|
|
|
|
Use after \\[widen]."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq ses--deferred-narrow t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-sort-column (sorter &optional reverse)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Sort the range by a specified column.
|
|
|
|
|
With prefix, sorts in REVERSE order."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*sSort column: \nP")
|
|
|
|
|
(ses-check-curcell 'needrange)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(let ((min (ses-sym-rowcol (car ses--curcell)))
|
|
|
|
|
(max (ses-sym-rowcol (cdr ses--curcell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((minrow (car min))
|
|
|
|
|
(mincol (cdr min))
|
|
|
|
|
(maxrow (car max))
|
|
|
|
|
(maxcol (cdr max))
|
|
|
|
|
keys extracts end)
|
|
|
|
|
(setq sorter (cdr (ses-sym-rowcol (intern (concat sorter "1")))))
|
|
|
|
|
(or (and sorter (>= sorter mincol) (<= sorter maxcol))
|
|
|
|
|
(error "Invalid sort column"))
|
|
|
|
|
;;Get key columns and sort them
|
|
|
|
|
(dotimes (x (- maxrow minrow -1))
|
|
|
|
|
(ses-goto-print (+ minrow x) sorter)
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
(setq end (next-single-property-change (point) 'cursor-intangible))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(push (cons (buffer-substring-no-properties (point) end)
|
|
|
|
|
(+ minrow x))
|
|
|
|
|
keys))
|
Remove redundant #' before lambda
* admin/unidata/unidata-gen.el (unidata-gen-table)
(unidata-gen-table-symbol, unidata-gen-table-integer)
(unidata-gen-table-numeric, unidata-gen-table-word-list)
(unidata-describe-decomposition):
* lisp/apropos.el (apropos-user-option):
* lisp/bookmark.el (bookmark-bmenu-search):
* lisp/composite.el (unicode-category-table):
* lisp/elec-pair.el (electric-pair--balance-info):
* lisp/electric.el (electric-quote-chars):
* lisp/emulation/cua-base.el (cua-rectangle-mark-key):
* lisp/epa-hook.el (epa-file-encrypt-to):
* lisp/faces.el (face-font-selection-order)
(face-font-family-alternatives, face-font-registry-alternatives)
(face-valid-attribute-values, tty-run-terminal-initialization):
* lisp/files.el (recover-file, file-expand-wildcards):
* lisp/frame.el (frames-on-display-list):
* lisp/help-at-pt.el (help-at-pt-display-when-idle):
* lisp/help-fns.el (help-fns--face-attributes):
* lisp/ido.el (ido-mode, ido-unc-hosts):
* lisp/isearch.el (isearch-highlight-regexp)
(isearch-highlight-lines-matching-regexp):
* lisp/language/indian.el (script-regexp-alist):
* lisp/language/lao.el:
* lisp/leim/quail/ipa.el (ipa-x-sampa-prepend-to-keymap-entry):
* lisp/mh-e/mh-folder.el (mh-process-commands):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer):
* lisp/ps-mule.el (ps-mule-end-job):
* lisp/ps-print.el (ps-color-scale, ps-background-pages)
(ps-background-text, ps-background-image, ps-background)
(ps-begin-job, ps-print-translation-table):
* lisp/recentf.el (recentf-sort-ascending)
(recentf-sort-descending, recentf-sort-basenames-ascending)
(recentf-sort-basenames-descending)
(recentf-sort-directories-ascending)
(recentf-sort-directories-descending):
* lisp/replace.el (occur-engine-add-prefix):
* lisp/select.el (xselect--encode-string):
* lisp/server.el (server-use-tcp):
* lisp/ses.el (ses-sort-column):
* lisp/sort.el (sort-columns):
* lisp/term/ns-win.el (window-system-initialization):
* lisp/tree-widget.el (tree-widget-image-formats):
* lisp/whitespace.el (whitespace-report-region): Remove redundant #'
before lambda.
2021-10-21 21:35:07 +00:00
|
|
|
|
(setq keys (sort keys (lambda (x y) (string< (car x) (car y)))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
;;Extract the lines in reverse sorted order
|
|
|
|
|
(or reverse
|
|
|
|
|
(setq keys (nreverse keys)))
|
|
|
|
|
(dolist (x keys)
|
|
|
|
|
(ses-goto-print (cdr x) (1+ maxcol))
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(ses-goto-print (cdr x) mincol)
|
|
|
|
|
(push (ses-copy-region (point) end) extracts))
|
|
|
|
|
(deactivate-mark)
|
|
|
|
|
;;Paste the lines sequentially
|
|
|
|
|
(dotimes (x (- maxrow minrow -1))
|
|
|
|
|
(ses-goto-print (+ minrow x) mincol)
|
|
|
|
|
(ses-set-curcell)
|
|
|
|
|
(ses-yank-cells (pop extracts) nil)))))
|
|
|
|
|
|
|
|
|
|
(defun ses-sort-column-click (event reverse)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
"Mouse version of `ses-sort-column'."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(interactive "*e\nP")
|
|
|
|
|
(setq event (event-end event))
|
|
|
|
|
(select-window (posn-window event))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(setq event (car (posn-col-row event))) ; Click column.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(let ((col 0))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(while (and (< col ses--numcols) (> event (ses-col-width col)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq event (- event (ses-col-width col) 1)
|
|
|
|
|
col (1+ col)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(if (>= col ses--numcols)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ding)
|
|
|
|
|
(ses-sort-column (ses-column-letter col) reverse))))
|
|
|
|
|
|
|
|
|
|
(defun ses-insert-range ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Insert into minibuffer the list of cells currently highlighted in the
|
2002-09-28 18:45:56 +00:00
|
|
|
|
spreadsheet."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(let (x)
|
|
|
|
|
(with-current-buffer (window-buffer minibuffer-scroll-window)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-command-hook) ; For ses-coverage.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell 'needrange)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq x (cdr (macroexpand `(ses-range ,(car ses--curcell)
|
|
|
|
|
,(cdr ses--curcell))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert (substring (prin1-to-string (nreverse x)) 1 -1))))
|
|
|
|
|
|
|
|
|
|
(defun ses-insert-ses-range ()
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Insert \"(ses-range x y)\" in the minibuffer to represent the currently
|
2002-09-28 18:45:56 +00:00
|
|
|
|
highlighted range in the spreadsheet."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(let (x)
|
|
|
|
|
(with-current-buffer (window-buffer minibuffer-scroll-window)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
(ses-command-hook) ; For ses-coverage.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-check-curcell 'needrange)
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(setq x (format "(ses-range %S %S)"
|
|
|
|
|
(car ses--curcell)
|
|
|
|
|
(cdr ses--curcell))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(insert x)))
|
|
|
|
|
|
|
|
|
|
(defun ses-insert-range-click (event)
|
|
|
|
|
"Mouse version of `ses-insert-range'."
|
|
|
|
|
(interactive "*e")
|
|
|
|
|
(mouse-set-point event)
|
|
|
|
|
(ses-insert-range))
|
|
|
|
|
|
|
|
|
|
(defun ses-insert-ses-range-click (event)
|
|
|
|
|
"Mouse version of `ses-insert-ses-range'."
|
|
|
|
|
(interactive "*e")
|
|
|
|
|
(mouse-set-point event)
|
|
|
|
|
(ses-insert-ses-range))
|
|
|
|
|
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(defun ses-replace-name-in-formula (formula old-name new-name)
|
|
|
|
|
(let ((new-formula formula))
|
2017-07-17 18:54:20 +00:00
|
|
|
|
(cond
|
|
|
|
|
((eq (car-safe formula) 'quote))
|
|
|
|
|
((symbolp formula)
|
|
|
|
|
(if (eq formula old-name)
|
|
|
|
|
(setq new-formula new-name)))
|
|
|
|
|
((consp formula)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
(while formula
|
|
|
|
|
(let ((elt (car-safe formula)))
|
|
|
|
|
(cond
|
|
|
|
|
((consp elt)
|
|
|
|
|
(setcar formula (ses-replace-name-in-formula elt old-name new-name)))
|
|
|
|
|
((and (symbolp elt)
|
|
|
|
|
(eq (car-safe formula) old-name))
|
|
|
|
|
(setcar formula new-name))))
|
2017-07-17 18:54:20 +00:00
|
|
|
|
(setq formula (cdr formula)))))
|
|
|
|
|
new-formula))
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(defun ses-rename-cell (new-name &optional cell)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Rename current cell."
|
|
|
|
|
(interactive "*SEnter new name: ")
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(or
|
|
|
|
|
(and (local-variable-p new-name)
|
|
|
|
|
(ses-is-cell-sym-p new-name)
|
|
|
|
|
(error "Already a cell name"))
|
|
|
|
|
(and (boundp new-name)
|
Top-level elisp files respect ‘text-quoting-style’
In top-level elisp files, use format-message in diagnostic formats,
so that they follow user preference as per ‘text-quoting-style’
rather than being hard-coded to quote `like this'.
* lisp/allout.el (allout-get-configvar-values):
* lisp/apropos.el (apropos-symbols-internal):
* lisp/dired-aux.el (dired-do-shell-command, dired-create-files)
(dired-do-create-files-regexp, dired-create-files-non-directory):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log, dired-dnd-handle-local-file):
* lisp/disp-table.el (standard-display-european):
* lisp/find-dired.el (find-dired):
* lisp/forms.el (forms-mode):
* lisp/ido.el (ido-buffer-internal):
* lisp/info.el (Info-index-next):
* lisp/outline.el (outline-invent-heading):
* lisp/printing.el (pr-ps-outfile-preprint, pr-i-ps-send):
* lisp/proced.el (proced-log):
* lisp/ps-print.el (ps-print-preprint, ps-get-size):
* lisp/recentf.el (recentf-open-files, recentf-save-list):
* lisp/savehist.el (savehist-save):
* lisp/server.el (server-ensure-safe-dir):
* lisp/ses.el (ses-rename-cell):
* lisp/simple.el (list-processes--refresh):
* lisp/startup.el (command-line):
* lisp/strokes.el (strokes-unset-last-stroke)
(strokes-execute-stroke):
Use format-message so that quotes are restyled.
* lisp/cus-edit.el (custom-raised-buttons, customize-browse):
Don’t quote ‘raised’.
* lisp/descr-text.el (describe-char):
* lisp/dirtrack.el (dirtrack-debug-message):
* lisp/hexl.el (hexl-insert-multibyte-char):
Apply substitute-command-keys to help string.
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
Let dired-log do the formatting.
2015-08-26 08:30:29 +00:00
|
|
|
|
(null (yes-or-no-p
|
|
|
|
|
(format-message
|
|
|
|
|
"`%S' is already bound outside this buffer, continue? "
|
|
|
|
|
new-name)))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(error "Already a bound cell name")))
|
|
|
|
|
(let* (curcell
|
|
|
|
|
(sym (if (ses-cell-p cell)
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(ses-cell-symbol cell)
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(setq cell nil
|
|
|
|
|
curcell t)
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(ses-check-curcell)
|
|
|
|
|
ses--curcell))
|
|
|
|
|
(rowcol (ses-sym-rowcol sym))
|
2012-07-20 21:09:04 +00:00
|
|
|
|
(row (car rowcol))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(col (cdr rowcol))
|
2017-07-13 18:58:22 +00:00
|
|
|
|
new-rowcol old-name old-value)
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(setq cell (or cell (ses-get-cell row col))
|
|
|
|
|
old-name (ses-cell-symbol cell)
|
2017-07-13 18:58:22 +00:00
|
|
|
|
old-value (symbol-value old-name)
|
2012-11-09 05:48:05 +00:00
|
|
|
|
new-rowcol (ses-decode-cell-symbol (symbol-name new-name)))
|
2016-05-26 09:03:21 +00:00
|
|
|
|
;; when ses-rename-cell is called interactively, then 'sym' is the
|
|
|
|
|
;; 'cursor-intangible' property of text at cursor position, while
|
|
|
|
|
;; 'old-name' is the symbol stored in array cell at coordinate
|
|
|
|
|
;; 'rowcol' corresponding to 'ses-cell' property of symbol
|
|
|
|
|
;; 'sym'. Both must be the same.
|
|
|
|
|
(unless (eq sym old-name)
|
2020-09-21 11:29:10 +00:00
|
|
|
|
(error "Spreadsheet is broken, both symbols %S and %S referring to cell (%d,%d)" sym old-name row col))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(if new-rowcol
|
2016-05-26 09:03:21 +00:00
|
|
|
|
;; the new name is of A1 type, so we test that the coordinate
|
2016-05-26 19:55:06 +00:00
|
|
|
|
;; inferred from new name
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(if (equal new-rowcol rowcol)
|
2016-05-26 09:03:21 +00:00
|
|
|
|
(put new-name 'ses-cell rowcol)
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(error "Not a valid name for this cell location"))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setq ses--named-cell-hashmap
|
|
|
|
|
(or ses--named-cell-hashmap (make-hash-table :test 'eq)))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(put new-name 'ses-cell :ses-named)
|
|
|
|
|
(puthash new-name rowcol ses--named-cell-hashmap))
|
|
|
|
|
(push `(ses-rename-cell ,old-name ,cell) buffer-undo-list)
|
2017-07-13 18:58:22 +00:00
|
|
|
|
(cl-pushnew rowcol ses--deferred-write :test #'equal)
|
2020-09-21 11:29:10 +00:00
|
|
|
|
;; Replace name by new name in formula of cells referring to renamed cell.
|
2012-07-20 21:09:04 +00:00
|
|
|
|
(dolist (ref (ses-cell-references cell))
|
|
|
|
|
(let* ((x (ses-sym-rowcol ref))
|
|
|
|
|
(xcell (ses-get-cell (car x) (cdr x))))
|
2017-07-13 18:58:22 +00:00
|
|
|
|
(cl-pushnew x ses--deferred-write :test #'equal)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-cell-formula xcell)
|
|
|
|
|
(ses-replace-name-in-formula
|
|
|
|
|
(ses-cell-formula xcell)
|
2016-05-26 09:03:21 +00:00
|
|
|
|
old-name
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
new-name))))
|
|
|
|
|
;; Replace name by new name in reference list of cells to which renamed
|
|
|
|
|
;; cell refers to.
|
2012-07-20 21:09:04 +00:00
|
|
|
|
(dolist (ref (ses-formula-references (ses-cell-formula cell)))
|
|
|
|
|
(let* ((x (ses-sym-rowcol ref))
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(xcell (ses-get-cell (car x) (cdr x))))
|
2017-07-13 18:58:22 +00:00
|
|
|
|
(cl-pushnew x ses--deferred-write :test #'equal)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-cell-references xcell)
|
2016-05-26 09:03:21 +00:00
|
|
|
|
(cons new-name (delq old-name
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(ses-cell-references xcell))))))
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(set (make-local-variable new-name) (symbol-value sym))
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(setf (ses-cell--symbol cell) new-name)
|
2017-07-13 18:58:22 +00:00
|
|
|
|
;; set new name to value
|
|
|
|
|
(set new-name old-value)
|
2016-05-26 09:03:21 +00:00
|
|
|
|
;; Unbind old name
|
|
|
|
|
(if (eq (get old-name 'ses-cell) :ses-named)
|
|
|
|
|
(ses--unbind-cell-name old-name)
|
|
|
|
|
(kill-local-variable old-name))
|
2012-11-09 05:48:05 +00:00
|
|
|
|
(and curcell (setq ses--curcell new-name))
|
2015-12-30 23:10:37 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(or curcell (ses-goto-print row col))
|
|
|
|
|
(let* ((pos (point))
|
|
|
|
|
(inhibit-read-only t)
|
Correct a whole bunch of bugs coming with renamed cell relocation.
* lisp/ses.el (ses-localvars): rename variable
`ses--renamed-cell-symb-list' into `ses--in-killing-named-cell-list'
and adjust the comment about it.
(ses-plist-delq): new defun.
(ses--ses-buffer-list): new defvar.
(ses--unbind-cell-name): new defun.
(ses-relocate-symbol): Do not relocate symbol when it is a named cell.
(ses-relocate-formula): Undo change of
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net that was
preventing relocation for named cell --- now doing this is delegated
to function `ses-relocate-symbol'.
(ses-relocate-range): In docstring, undo change of
2016-01-03T07:31:52Z!johnw@newartisans.com, `ses-range' must remain
lower case as it is not a variable.
(ses-relocate-all): Cell name relocation : 1) check that cell is a
renamed cell by testing `ses-cell' property to :ses-named, rather than
comparing name to corresponding standard name. Set rowcol of renamed
cell into the hashmap --- `ses-cell' property must not be used for
that as the same name can be used for different locations in different
SES sheets ; 2) use `local-variable-if-set-p' rather than `boundp' and
`local-variable-p' to check if cell name is already in use in this
sheet or needs initialisation.
(ses-relocate-all): Cell value relocation : 1) like for name
relocation use the `ses-cell' property rather than comparing actual
name to corresponding standard name. 2) Correct bug introduced in
2011-12-27T19:30:39Z!vincentb1@users.sourceforge.net, as the test was
made the other way round than the intention --- ie value relocation
was disabled for standard cell, not for renamed cell as was the
intention.
(ses-relocate-all): Add loop for unbinding deleted renamed cells
names.
(ses-killbuffer-hook): new defun.
(ses-mode): Add the ses--ses-buffer-list maintenance mechanism ---
kill buffer hook, plus pushing current buffer if new in list.
(ses-delete-row, ses-delete-column): Collect deleted renamed cells
into `ses--in-killing-named-cell-list'.
(ses-rename-cell): Remove update of variable
`ses--renamed-cell-symb-list', this variable is renamed to
`ses--in-killing-named-cell-list', and its setting is done in
functions `ses-delete-row' and , `ses-delete-column' now.
(ses-rename-cell): Change correction of
2015-12-30T23:10:37Z!vincentb1@users.sourceforge.net concerning
computation of the range over which `cursor-intangible' property was
to be updated. This correction was ok for non spilling cells, but not
for cells spilling over following blank cells. Simply use
`next-single-property-change' rather than computing the end column
from column widths.
2016-01-20 07:28:06 +00:00
|
|
|
|
(end (next-single-property-change pos 'cursor-intangible)))
|
2015-12-30 23:10:37 +00:00
|
|
|
|
(put-text-property pos end 'cursor-intangible new-name)))
|
Deprecate `intangible' and `point-entered' properties
* lisp/emacs-lisp/cursor-sensor.el: New file.
* lisp/simple.el (pre-redisplay-functions): New hook.
(redisplay--pre-redisplay-functions): New function.
(pre-redisplay-function): Use it.
(minibuffer-avoid-prompt): Mark obsolete.
(redisplay--update-region-highlight): Adapt it to work as a function on
pre-redisplay-functions.
* lisp/cus-start.el (minibuffer-prompt-properties--setter): New fun.
(minibuffer-prompt-properties): Use it. Use cursor-intangible rather
than point-entered to make the prompt intangible.
* lisp/forms.el: Move `provide' calls to the end.
(forms-mode): Don't use `run-hooks' on a local var.
(forms--make-format, forms--make-format-elt-using-text-properties):
Use cursor-intangible rather than `intangible'.
(forms-mode): Enable cursor-intangible-mode.
* lisp/isearch.el (isearch-mode): Use defvar-local.
(cursor-sensor-inhibit): Declare.
(isearch-mode): Set cursor-sensor-inhibit.
(isearch-done): Set it back.
(isearch-open-overlay-temporary, isearch-open-necessary-overlays)
(isearch-close-unnecessary-overlays): Don't bother with `intangible'
any more.
* lisp/ses.el (ses-localvars): Remove `mode-line-process'.
(ses-sym-rowcol, ses-cell-value, ses-col-width, ses-col-printer):
Add Edebug spec.
(ses-goto-print, ses-print-cell, ses-adjust-print-width)
(ses-goto-data, ses-setup, ses-copy-region): Don't let-bind
inhibit-point-motion-hooks any more.
(ses--cell-at-pos, ses--curcell): New functions, extracted from
ses-set-curcell.
(ses-set-curcell): Use them.
(ses-print-cell, ses-setup): Use cursor-intangible instead of
`intangible'. Make sure cursor-intangible isn't sticky at BOB.
(ses-print-cell-new-width, ses-reprint-all, ses-recalculate-all):
Use ses--cell-at-pos.
(ses--mode-line-process, ses--cursor-sensor-highlight): New functions,
extracted from ses-command-hook. Make them work with multiple windows
displaying the same buffer.
(ses-mode): Use them via mode-line-process and pre-redisplay-functions.
Enable cursor-intangible-mode.
(ses-command-hook): Remove cell highlight and mode-line update code.
(ses-forward-or-insert, ses-copy-region-helper, ses-sort-column):
Update for new name of text-property holding the cell name.
(ses-rename-cell): Don't mess with mode-line-process.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Use the new
cursor-sensor-functions property instead of point-entered.
(erc-insert-timestamp-right, erc-format-timestamp):
Use cursor-intangible rather than `intangible'.
(erc-munge-invisibility-spec): Use add-to-invisibility-spec and
remove-from-invisibility-spec. Enable cursor-intangible-mode and
cursor-sensor-mode if needed.
(erc-echo-timestamp): Adapt to calling convention of
cursor-sensor-functions.
(erc-insert-timestamp-right): Remove unused vars `current-window' and
`indent'.
* lisp/gnus/gnus-group.el (gnus-tmp-*): Declare.
(gnus-update-group-mark-positions): Remove unused `topic' var.
(gnus-group-insert-group-line): Remove unused var `header'.
(gnus-group--setup-tool-bar-update): New function.
(gnus-group-insert-group-line): Use it.
(gnus-group-update-eval-form): Declare local
dynamically-bound variables.
(gnus-group-unsubscribe-group): Use \` and \' to match string bounds.
* lisp/gnus/gnus-topic.el (gnus-topic-jump-to-topic)
(gnus-group-prepare-topics, gnus-topic-update-topic)
(gnus-topic-change-level, gnus-topic-catchup-articles)
(gnus-topic-remove-group, gnus-topic-delete, gnus-topic-indent):
Use inhibit-read-only.
(gnus-topic-prepare-topic): Use gnus-group--setup-tool-bar-update.
(gnus-topic-mode): Use define-minor-mode and derived-mode-p.
* lisp/textmodes/reftex-index.el (reftex-display-index):
Use cursor-intangible-mode if available.
(reftex-index-post-command-hook): Check cursor-intangible.
* lisp/textmodes/reftex-toc.el (reftex-toc):
Use cursor-intangible-mode if available.
(reftex-toc-recenter, reftex-toc-post-command-hook):
Check cursor-intangible.
* lisp/textmodes/sgml-mode.el: Use lexical-binding.
(sgml-tag): Use cursor-sensor-functions instead of point-entered.
(sgml-tags-invisible): Use with-silent-modifications and
inhibit-read-only. Enable cursor-sensor-mode.
(sgml-cursor-sensor): Rename from sgml-point-entered and adjust to
calling convention of cursor-sensor-functions.
* lisp/textmodes/table.el (table-cell-map-hook, table-load-hook)
(table-point-entered-cell-hook, table-point-left-cell-hook):
Don't autoload.
(table-cell-entered-state): Remove var.
(table--put-cell-point-entered/left-property)
(table--remove-cell-properties):
Use cursor-sensor-functions rather than point-entered/left.
(table--point-entered/left-cell-function): Merge
table--point-entered-cell-function and table--point-left-cell-function
and adjust to calling convention of cursor-sensor-functions.
2015-04-13 19:51:15 +00:00
|
|
|
|
;; Update the cell name in the mode-line.
|
2012-07-22 21:14:12 +00:00
|
|
|
|
(force-mode-line-update)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2014-09-29 20:25:19 +00:00
|
|
|
|
(defun ses-refresh-local-printer (name _compiled-value) ;FIXME: unused arg?
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
"Refresh printout for all cells which use printer NAME.
|
|
|
|
|
NAME should be the name of a locally defined printer.
|
|
|
|
|
Uses the value COMPILED-VALUE for this printer."
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(message "Refreshing cells using printer %S" name)
|
|
|
|
|
(let (new-print)
|
|
|
|
|
(dotimes (row ses--numrows)
|
|
|
|
|
(dotimes (col ses--numcols)
|
|
|
|
|
(let ((cell-printer (ses-cell-printer row col)))
|
|
|
|
|
(when (eq cell-printer name)
|
|
|
|
|
(unless new-print
|
|
|
|
|
(setq new-print t)
|
|
|
|
|
(ses-begin-change))
|
|
|
|
|
(ses-print-cell row col)))))))
|
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-define-local-printer (name definition)
|
|
|
|
|
"Define a local printer with name NAME and definition DEFINITION.
|
|
|
|
|
|
2021-09-14 06:43:18 +00:00
|
|
|
|
NAME shall be a symbol. Use TAB to complete over existing local
|
2016-07-28 15:41:21 +00:00
|
|
|
|
printer names.
|
|
|
|
|
|
|
|
|
|
DEFINITION shall be either a string formatter, e.g.:
|
|
|
|
|
|
|
|
|
|
\"%.2f\" or (\"%.2f\") for left alignment.
|
|
|
|
|
|
|
|
|
|
or a lambda expression, e.g. for formatting in ISO format dates
|
|
|
|
|
created with a '(calcFunc-date YEAR MONTH DAY)' formula:
|
|
|
|
|
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(cond
|
|
|
|
|
((null val) \"\")
|
|
|
|
|
((eq (car-safe x) 'date)
|
|
|
|
|
(let ((calc-format-date '(X YYYY \"-\" MM \"-\" DD)))
|
|
|
|
|
(math-format-date x)))
|
|
|
|
|
(t (ses-center-span val ?# 'ses-prin1))))
|
|
|
|
|
|
|
|
|
|
If NAME is already used to name a local printer function, then
|
|
|
|
|
the current definition is proposed as default value, and the
|
|
|
|
|
function is redefined."
|
|
|
|
|
(interactive
|
|
|
|
|
(let (name def already-defined-names)
|
2017-04-03 03:09:53 +00:00
|
|
|
|
(maphash (lambda (key _val) (push (symbol-name key) already-defined-names))
|
2016-07-28 15:41:21 +00:00
|
|
|
|
ses--local-printer-hashmap)
|
|
|
|
|
(setq name (completing-read "Enter printer name: " already-defined-names))
|
|
|
|
|
(when (string= name "")
|
|
|
|
|
(error "Invalid printer name"))
|
|
|
|
|
(setq name (intern name))
|
|
|
|
|
(let* ((cur-printer (gethash name ses--local-printer-hashmap))
|
|
|
|
|
(default (and cur-printer (ses--locprn-def cur-printer))))
|
2021-10-05 01:34:08 +00:00
|
|
|
|
(setq def (ses-read-printer (format-prompt
|
|
|
|
|
"Enter definition of printer %S"
|
|
|
|
|
default name)
|
2016-07-28 15:41:21 +00:00
|
|
|
|
default)))
|
|
|
|
|
(list name def)))
|
|
|
|
|
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let* ((cur-printer (gethash name ses--local-printer-hashmap))
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(default (and cur-printer (ses--locprn-def cur-printer)))
|
|
|
|
|
create-printer)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(cond
|
|
|
|
|
;; cancelled operation => do nothing
|
2016-07-28 15:41:21 +00:00
|
|
|
|
((eq definition t))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; no change => do nothing
|
2016-07-28 15:41:21 +00:00
|
|
|
|
((and cur-printer (equal definition default)))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; re-defined printer
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(cur-printer
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(setq create-printer 0)
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(setf (ses--locprn-def cur-printer) definition)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(ses-refresh-local-printer
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
name
|
|
|
|
|
(setf (ses--locprn-compiled cur-printer)
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-local-printer-compile definition))))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
;; new definition
|
|
|
|
|
(t
|
|
|
|
|
(setq create-printer 1)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(puthash name
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(setq cur-printer
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-make-local-printer-info definition))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
ses--local-printer-hashmap)))
|
|
|
|
|
(when create-printer
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(let ((printer-def-text
|
|
|
|
|
(concat
|
|
|
|
|
"(ses-local-printer "
|
|
|
|
|
(symbol-name name)
|
|
|
|
|
" "
|
|
|
|
|
(prin1-to-string (ses--locprn-def cur-printer))
|
|
|
|
|
")")))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(ses-goto-data ses--numrows
|
|
|
|
|
(ses--locprn-number cur-printer))
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
;; Special undo since it's outside the narrowed buffer.
|
|
|
|
|
(let (buffer-undo-list)
|
|
|
|
|
(if (= create-printer 0)
|
|
|
|
|
(delete-region (point) (line-end-position))
|
|
|
|
|
(insert ?\n)
|
|
|
|
|
(backward-char))
|
|
|
|
|
(insert printer-def-text)
|
|
|
|
|
(when (= create-printer 1)
|
2014-09-11 19:44:25 +00:00
|
|
|
|
(ses-file-format-extend-parameter-list 3)
|
* lisp/ses.el: Miscellaneous cleanups; use lexical-binding; avoid add-to-list.
(ses-localvars): Remove ses--local-printer-list, unused.
(ses--metaprogramming): New macro. Use it to defvar variables.
(ses-set-localvars): Simplify.
(ses--locprn, ses-cell): Use defstruct. Change ses-cell's
property-list into an alist.
(ses-locprn-get-compiled, ses-locprn-compiled-aset)
(ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number):
Remove; use defstruct accessors/setters instead.
(ses-cell-formula-aset, ses-cell-printer-aset)
(ses-cell-references-aset): Remove, use setf instead.
(ses--alist-get): New function.
(ses-cell-property): Rename from ses-cell-property-get and rewrite.
Use an alist instead of a plist and don't do move-to-front since the
list is always short.
(ses-cell-property-get-fun, ses-cell-property-delq-fun)
(ses-cell-property-set-fun, ses-cell-property-set)
(ses-cell-property-pop-fun, ses-cell-property-get-handle)
(ses-cell-property-handle-car, ses-cell-property-handle-setcar): Remove.
(ses--letref): New macro.
(ses-cell-property-pop): Rewrite.
(ses--cell): Rename from ses-cell and make it into a function.
Make `formula' fallback on `value' if nil.
(ses--local-printer): Rename from ses-local-printer and make it into
a function.
(ses-set-cell): Turn it into a macro so finding the accessor from the
field name is done at compile time.
(ses-repair-cell-reference-all): Test presence of `sym' rather than
`ref' before adding `sym' to :ses-repair-reference.
(ses-calculate-cell): Use ses--letref rather than
ses-cell-property-get-handle.
(ses-write-cells): Use a single prin1-to-string.
(ses-setter-with-undo): New function.
(ses-aset-with-undo, ses-set-with-undo): Rewrite using it.
(ses-unset-with-undo): Remove.
(ses-load): Prefer apply' over `eval'.
(ses-read-printer, ses-set-column-width): Use standard "(default
foo)" format.
2014-06-15 04:10:40 +00:00
|
|
|
|
(ses-set-parameter 'ses--numlocprn
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(1+ ses--numlocprn))))))))))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defsubst ses-define-if-new-local-printer (name def)
|
|
|
|
|
"Same as function `ses-define-if-new-local-printer', except
|
|
|
|
|
that the definition occurs only when the local printer does not
|
|
|
|
|
already exists.
|
|
|
|
|
|
2016-08-05 20:31:10 +00:00
|
|
|
|
Function `ses-define-if-new-local-printer' is not interactive; it
|
|
|
|
|
is intended for mode hooks to add local printers automatically."
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(unless (gethash name ses--local-printer-hashmap)
|
|
|
|
|
(ses-define-local-printer name def)))
|
2014-06-12 06:04:48 +00:00
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Checking formulas for safety
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-safe-printer (printer)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Return PRINTER if safe, or the substitute printer `ses-unsafe' otherwise."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (or (stringp printer)
|
|
|
|
|
(stringp (car-safe printer))
|
|
|
|
|
(not printer)
|
2014-06-12 06:04:48 +00:00
|
|
|
|
(and (symbolp printer) (gethash printer ses--local-printer-hashmap))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-warn-unsafe printer 'unsafep-function))
|
|
|
|
|
printer
|
|
|
|
|
'ses-unsafe))
|
|
|
|
|
|
|
|
|
|
(defun ses-safe-formula (formula)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Return FORMULA if safe, or the substitute formula *unsafe* otherwise."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (ses-warn-unsafe formula 'unsafep)
|
|
|
|
|
formula
|
|
|
|
|
`(ses-unsafe ',formula)))
|
|
|
|
|
|
|
|
|
|
(defun ses-warn-unsafe (formula checker)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Apply CHECKER to FORMULA.
|
|
|
|
|
If result is non-nil, asks user for confirmation about FORMULA,
|
|
|
|
|
which might be unsafe. Returns t if formula is safe or user allows
|
|
|
|
|
execution anyway. Always returns t if `safe-functions' is t."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (eq safe-functions t)
|
|
|
|
|
t
|
|
|
|
|
(setq checker (funcall checker formula))
|
|
|
|
|
(if (not checker)
|
|
|
|
|
t
|
|
|
|
|
(y-or-n-p (format "Formula %S\nmight be unsafe %S. Process it? "
|
|
|
|
|
formula checker)))))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Standard formulas
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(defun ses--clean-! (&rest x)
|
2015-05-21 17:04:45 +00:00
|
|
|
|
"Clean by `delq' list X from any occurrence of nil or `*skip*'."
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(delq nil (delq '*skip* x)))
|
|
|
|
|
|
|
|
|
|
(defun ses--clean-_ (x y)
|
2015-05-21 17:04:45 +00:00
|
|
|
|
"Clean list X by replacing by Y any occurrence of nil or `*skip*'.
|
2011-06-27 06:18:45 +00:00
|
|
|
|
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
This will change X by making `setcar' on its cons cells."
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(let ((ret x) ret-elt)
|
|
|
|
|
(while ret
|
|
|
|
|
(setq ret-elt (car ret))
|
|
|
|
|
(when (memq ret-elt '(nil *skip*))
|
|
|
|
|
(setcar ret y))
|
|
|
|
|
(setq ret (cdr ret))))
|
|
|
|
|
x)
|
|
|
|
|
|
|
|
|
|
(defmacro ses-range (from to &rest rest)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Expand to a list of cell-symbols for the range going from
|
2011-06-27 06:18:45 +00:00
|
|
|
|
FROM up to TO. The range automatically expands to include any
|
|
|
|
|
new row or column inserted into its middle. The SES library code
|
|
|
|
|
specifically looks for the symbol `ses-range', so don't create an
|
|
|
|
|
alias for this macro!
|
|
|
|
|
|
|
|
|
|
By passing in REST some flags one can configure the way the range
|
|
|
|
|
is read and how it is formatted.
|
|
|
|
|
|
|
|
|
|
In the sequel we assume that cells A1, B1, A2 B2 have respective values
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
1 2 3 and 4.
|
2011-06-27 06:18:45 +00:00
|
|
|
|
|
2015-11-17 23:28:50 +00:00
|
|
|
|
Readout direction is specified by a `>v', `>^', `<v', `<^',
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
`v>', `v<', `^>', `^<' flag. For historical reasons, in absence
|
|
|
|
|
of such a flag, a default direction of `^<' is assumed. This
|
2011-06-27 06:18:45 +00:00
|
|
|
|
way `(ses-range A1 B2 ^>)' will evaluate to `(1 3 2 4)',
|
|
|
|
|
while `(ses-range A1 B2 >^)' will evaluate to (3 4 1 2).
|
|
|
|
|
|
|
|
|
|
If the range is one row, then `>' can be used as a shorthand to
|
|
|
|
|
`>v' or `>^', and `<' to `<v' or `<^'.
|
|
|
|
|
|
|
|
|
|
If the range is one column, then `v' can be used as a shorthand to
|
|
|
|
|
`v>' or `v<', and `^' to `^>' or `v<'.
|
|
|
|
|
|
|
|
|
|
A `!' flag will remove all cells whose value is nil or `*skip*'.
|
|
|
|
|
|
|
|
|
|
A `_' flag will replace nil or `*skip*' by the value following
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
the `_' flag. If the `_' flag is the last argument, then they are
|
2011-06-27 06:18:45 +00:00
|
|
|
|
replaced by integer 0.
|
|
|
|
|
|
|
|
|
|
A `*', `*1' or `*2' flag will vectorize the range in the sense of
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
Calc. See info node `(Calc) Top'. Flag `*' will output either a
|
2011-06-27 06:18:45 +00:00
|
|
|
|
vector or a matrix depending on the number of rows, `*1' will
|
|
|
|
|
flatten the result to a one row vector, and `*2' will make a
|
|
|
|
|
matrix whatever the number of rows.
|
|
|
|
|
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
Warning: interaction with Calc is experimental and may produce
|
|
|
|
|
confusing results if you are not aware of Calc data format.
|
|
|
|
|
Use `math-format-value' as a printer for Calc objects."
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(let (result-row
|
|
|
|
|
result
|
|
|
|
|
(prev-row -1)
|
|
|
|
|
(reorient-x nil)
|
|
|
|
|
(reorient-y nil)
|
|
|
|
|
transpose vectorize
|
|
|
|
|
(clean 'list))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(ses-dorange (cons from to)
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(when (/= prev-row row)
|
|
|
|
|
(push result-row result)
|
|
|
|
|
(setq result-row nil))
|
|
|
|
|
(push (ses-cell-symbol row col) result-row)
|
|
|
|
|
(setq prev-row row))
|
|
|
|
|
(push result-row result)
|
|
|
|
|
(while rest
|
|
|
|
|
(let ((x (pop rest)))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(pcase x
|
2018-11-05 00:22:15 +00:00
|
|
|
|
('>v (setq transpose nil reorient-x nil reorient-y nil))
|
|
|
|
|
('>^ (setq transpose nil reorient-x nil reorient-y t))
|
|
|
|
|
('<^ (setq transpose nil reorient-x t reorient-y t))
|
|
|
|
|
('<v (setq transpose nil reorient-x t reorient-y nil))
|
|
|
|
|
('v> (setq transpose t reorient-x nil reorient-y t))
|
|
|
|
|
('^> (setq transpose t reorient-x nil reorient-y nil))
|
|
|
|
|
('^< (setq transpose t reorient-x t reorient-y nil))
|
|
|
|
|
('v< (setq transpose t reorient-x t reorient-y t))
|
|
|
|
|
((or '* '*2 '*1) (setq vectorize x))
|
|
|
|
|
('! (setq clean 'ses--clean-!))
|
|
|
|
|
('_ (setq clean `(lambda (&rest x)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(ses--clean-_ x ,(if rest (pop rest) 0)))))
|
|
|
|
|
(_
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(cond
|
|
|
|
|
; shorthands one row
|
|
|
|
|
((and (null (cddr result)) (memq x '(> <)))
|
|
|
|
|
(push (intern (concat (symbol-name x) "v")) rest))
|
|
|
|
|
; shorthands one col
|
|
|
|
|
((and (null (cdar result)) (memq x '(v ^)))
|
|
|
|
|
(push (intern (concat (symbol-name x) ">")) rest))
|
|
|
|
|
(t (error "Unexpected flag `%S' in ses-range" x)))))))
|
|
|
|
|
(if reorient-y
|
|
|
|
|
(setcdr (last result 2) nil)
|
|
|
|
|
(setq result (cdr (nreverse result))))
|
|
|
|
|
(unless reorient-x
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq result (mapcar #'nreverse result)))
|
2011-06-27 06:18:45 +00:00
|
|
|
|
(when transpose
|
|
|
|
|
(let ((ret (mapcar (lambda (x) (list x)) (pop result))) iter)
|
|
|
|
|
(while result
|
|
|
|
|
(setq iter ret)
|
|
|
|
|
(dolist (elt (pop result))
|
|
|
|
|
(setcar iter (cons elt (car iter)))
|
|
|
|
|
(setq iter (cdr iter))))
|
|
|
|
|
(setq result ret)))
|
|
|
|
|
|
2012-06-27 15:11:28 +00:00
|
|
|
|
(cl-flet ((vectorize-*1
|
|
|
|
|
(clean result)
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(cons clean (cons (quote 'vec) (apply #'append result))))
|
2012-06-27 15:11:28 +00:00
|
|
|
|
(vectorize-*2
|
|
|
|
|
(clean result)
|
|
|
|
|
(cons clean (cons (quote 'vec)
|
|
|
|
|
(mapcar (lambda (x)
|
|
|
|
|
(cons clean (cons (quote 'vec) x)))
|
|
|
|
|
result)))))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(pcase vectorize
|
2018-11-05 00:22:15 +00:00
|
|
|
|
('nil (cons clean (apply #'append result)))
|
|
|
|
|
('*1 (vectorize-*1 clean result))
|
|
|
|
|
('*2 (vectorize-*2 clean result))
|
|
|
|
|
('* (funcall (if (cdr result)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
#'vectorize-*2
|
|
|
|
|
#'vectorize-*1)
|
|
|
|
|
clean result))))))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-delete-blanks (&rest args)
|
|
|
|
|
"Return ARGS reversed, with the blank elements (nil and *skip*) removed."
|
|
|
|
|
(let (result)
|
|
|
|
|
(dolist (cur args)
|
2016-08-09 21:46:13 +00:00
|
|
|
|
(unless (memq cur '(nil *skip*))
|
2004-11-22 01:21:07 +00:00
|
|
|
|
(push cur result)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
result))
|
|
|
|
|
|
|
|
|
|
(defun ses+ (&rest args)
|
|
|
|
|
"Compute the sum of the arguments, ignoring blanks."
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(apply #'+ (apply #'ses-delete-blanks args)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defun ses-average (list)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Calculate the sum of the numbers in LIST, divided by their length.
|
|
|
|
|
Blanks are ignored. Result is always floating-point, even if all
|
|
|
|
|
args are integers."
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq list (apply #'ses-delete-blanks list))
|
|
|
|
|
(/ (float (apply #'+ list)) (length list)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
|
|
|
|
(defmacro ses-select (fromrange test torange)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Select cells in FROMRANGE that are `equal' to TEST.
|
|
|
|
|
For each match, return the corresponding cell from TORANGE.
|
|
|
|
|
The ranges are macroexpanded but not evaluated so they should be
|
|
|
|
|
either (ses-range BEG END) or (list ...). The TEST is evaluated."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq fromrange (cdr (macroexpand fromrange))
|
|
|
|
|
torange (cdr (macroexpand torange))
|
2014-09-30 17:52:11 +00:00
|
|
|
|
test (eval test t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or (= (length fromrange) (length torange))
|
|
|
|
|
(error "ses-select: Ranges not same length"))
|
|
|
|
|
(let (result)
|
|
|
|
|
(dolist (x fromrange)
|
|
|
|
|
(if (equal test (symbol-value x))
|
|
|
|
|
(push (car torange) result))
|
|
|
|
|
(setq torange (cdr torange)))
|
|
|
|
|
(cons 'list result)))
|
|
|
|
|
|
|
|
|
|
;;All standard formulas are safe
|
2006-09-29 02:42:39 +00:00
|
|
|
|
(dolist (x '(ses-cell-value ses-range ses-delete-blanks ses+ ses-average
|
|
|
|
|
ses-select))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(put x 'side-effect-free t))
|
|
|
|
|
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;----------------------------------------------------------------------------
|
|
|
|
|
;; Standard print functions
|
|
|
|
|
;;----------------------------------------------------------------------------
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defun ses-center (value &optional span fill printer)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Print VALUE, centered within column.
|
|
|
|
|
FILL is the fill character for centering (default = space).
|
|
|
|
|
SPAN indicates how many additional rightward columns to include
|
2016-07-28 15:41:21 +00:00
|
|
|
|
in width (default = 0).
|
|
|
|
|
PRINTER is the printer to use for printing the value, default is the
|
|
|
|
|
column printer if any, or the spreadsheet the spreadsheet default
|
|
|
|
|
printer otherwise."
|
|
|
|
|
(setq printer (or printer (ses-col-printer ses--col) ses--default-printer))
|
|
|
|
|
(let ((width (ses-col-width ses--col))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
half)
|
2005-07-04 02:27:03 +00:00
|
|
|
|
(or fill (setq fill ?\s))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(or span (setq span 0))
|
|
|
|
|
(setq value (ses-call-printer printer value))
|
|
|
|
|
(dotimes (x span)
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(setq width (+ width 1 (ses-col-width (+ ses--col span (- x))))))
|
2011-06-27 05:41:58 +00:00
|
|
|
|
;; Set column width.
|
2008-05-15 19:24:57 +00:00
|
|
|
|
(setq width (- width (string-width value)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(if (<= width 0)
|
2011-06-27 05:41:58 +00:00
|
|
|
|
value ; Too large for field, anyway.
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq half (make-string (/ width 2) fill))
|
|
|
|
|
(concat half value half
|
|
|
|
|
(if (> (% width 2) 0) (char-to-string fill))))))
|
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defun ses-center-span (value &optional fill printer)
|
2002-09-28 18:45:56 +00:00
|
|
|
|
"Print VALUE, centered within the span that starts in the current column
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
and continues until the next nonblank column.
|
|
|
|
|
FILL specifies the fill character (default = space)."
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(let ((end (1+ ses--col)))
|
2004-02-14 23:56:51 +00:00
|
|
|
|
(while (and (< end ses--numcols)
|
2014-09-30 17:52:11 +00:00
|
|
|
|
(memq (ses-cell-value ses--row end) '(nil *skip*)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(setq end (1+ end)))
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-center value (- end ses--col 1) fill printer)))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defun ses-dashfill (value &optional span printer)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Print VALUE centered using dashes.
|
|
|
|
|
SPAN indicates how many rightward columns to include in width (default = 0)."
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-center value span ?- printer))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defun ses-dashfill-span (value &optional printer)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
"Print VALUE, centered using dashes.
|
|
|
|
|
Centers within the span that starts in the current column and continues
|
|
|
|
|
until the next nonblank column."
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-center-span value ?- printer))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(defun ses-tildefill-span (value &optional printer)
|
2022-04-06 18:42:33 +00:00
|
|
|
|
"Print VALUE, centered using tildes.
|
|
|
|
|
Centers within the span that starts in the current column and continues
|
|
|
|
|
until the next nonblank column."
|
2016-07-28 15:41:21 +00:00
|
|
|
|
(ses-center-span value ?~ printer))
|
|
|
|
|
|
|
|
|
|
(defun ses-prin1 (value)
|
|
|
|
|
"Shorthand for '(prin1-to-string VALUE t)'.
|
2016-08-05 20:31:10 +00:00
|
|
|
|
Useful to handle the default behavior in custom lambda based
|
2016-07-28 15:41:21 +00:00
|
|
|
|
printer functions."
|
|
|
|
|
(prin1-to-string value t))
|
2002-09-28 18:45:56 +00:00
|
|
|
|
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 15:17:29 +00:00
|
|
|
|
(defun ses-unsafe (_value)
|
The overall change is to add cell renaming, that is setting fancy names for cell symbols other than name matching "\\`[A-Z]+[0-9]+\\'" regexp . (ses-create-cell-variable): New defun. (ses-relocate-formula): Relocate formulas only for cells the symbols of which are not renamed, i.e. symbols whose names do not match regexp "\\`[A-Z]+[0-9]+\\'". (ses-relocate-all): Relocate values only for cells the symbols of which are not renamed. (ses-load): Create cells variables as the (ses-cell ...) are read, in order to check row col consistency with cell symbol name only for cells that are not renamed. (ses-replace-name-in-formula): New defun. (ses-rename-cell): New defun. (ses-call-printer-return, ses-cell-property-get) (ses-sym-rowcol, ses-printer-validate, ses-formula-record) (ses-create-cell-variable, ses-reset-header-string) (ses-cell-set-formula, ses-repair-cell-reference-all) (ses-self-reference-early-detection, ses-in-print-area, ses-set-curcell) (ses-check-curcell, ses-call-printer, ses-adjust-print-width) (ses-print-cell-new-width, ses-formula-references, ses-relocate-formula) (ses-aset-with-undo, ses-load, ses-truncate-cell) (ses-read-column-printer, ses-read-default-printer, ses-insert-row) (ses-delete-row, ses-delete-column, ses-append-row-jump-first-column) (ses-kill-override, ses-yank-pop, ses-yank-cells, ses-yank-tsf) (ses-yank-resize, ses-export-tab, ses-mark-row, ses-mark-column) (ses-renarrow-buffer, ses-insert-range, ses-insert-ses-range) (ses-safe-printer, ses-safe-formula, ses-warn-unsafe, ses--clean-!) (ses--clean-_, ses-range, ses-select, ses-center, ses-center-span) (ses-dashfill, ses-unsafe): Fix typos and reflow docstrings.
2011-12-27 19:30:39 +00:00
|
|
|
|
"Substitute for an unsafe formula or printer."
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(error "Unsafe formula or printer"))
|
|
|
|
|
|
|
|
|
|
;;All standard printers are safe, including ses-unsafe!
|
|
|
|
|
(dolist (x (cons 'ses-unsafe ses-standard-printer-functions))
|
|
|
|
|
(put x 'side-effect-free t))
|
|
|
|
|
|
2007-10-30 00:21:42 +00:00
|
|
|
|
(defun ses-unload-function ()
|
|
|
|
|
"Unload the Simple Emacs Spreadsheet."
|
2012-12-06 20:16:38 +00:00
|
|
|
|
(advice-remove 'yank #'ses--advice-yank)
|
|
|
|
|
(advice-remove 'copy-region-as-kill #'ses--advice-copy-region-as-kill)
|
|
|
|
|
;; Continue standard unloading.
|
2007-10-30 00:21:42 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
2002-09-28 18:45:56 +00:00
|
|
|
|
(provide 'ses)
|
|
|
|
|
|
2004-11-22 01:21:07 +00:00
|
|
|
|
;;; ses.el ends here
|