Function: ses--advice-yank

ses--advice-yank is a byte-compiled function defined in ses.el.gz.

Signature

(ses--advice-yank YANK-FUN &optional ARG &rest ARGS)

Documentation

In SES mode, the yanked text is inserted as cells.

If the text contains ses attributes (meaning it went to the kill-ring from a 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 generally refer to other cells within the yanked text. You can use the C-u (universal-argument) prefix to specify insertion without relocation, which is best when the formulas refer to cells outside the yanked text.

When inserting formulas, the text is treated as a string constant if it doesn't make sense as a sexp or would otherwise be considered a symbol. Use sym to explicitly insert a symbol, or use the C-u (universal-argument) prefix to treat all unmarked words as symbols.

Source Code

;; Defined in /usr/src/emacs/lisp/ses.el.gz
(defun ses--advice-yank (yank-fun &optional arg &rest args)
  "In SES mode, the yanked text is inserted as cells.

If the text contains `ses' attributes (meaning it went to the kill-ring from a
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
generally refer to other cells within the yanked text.  You can use the \\[universal-argument]
prefix to specify insertion without relocation, which is best when the
formulas refer to cells outside the yanked text.

When inserting formulas, the text is treated as a string constant if it doesn't
make sense as a sexp or would otherwise be considered a symbol.  Use `sym' to
explicitly insert a symbol, or use the \\[universal-argument] prefix to treat all unmarked words
as symbols."
  (if (not (and (derived-mode-p 'ses-mode)
		(eq (get-text-property (point) 'keymap) 'ses-mode-print-map)))
      (apply yank-fun arg args) ; Normal non-SES yank.
    (ses-check-curcell 'end)
    (push-mark)
    (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))
			    ;; Just one cell --- delete final tab or newline.
			    (1- (length text)))
			arg)))
    (if (consp arg)
	(exchange-point-and-mark))))