comparison lisp/textmodes/table.el @ 90268:d88caeac70d7

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-2 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (base, patch 1-3) - tag of miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-704 - Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 (patch 700-704) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/cus-edit.el (customize-rogue): Minor doc fix. * miles@gnu.org--gnu-2005/gnus--rel--5.10 (patch 185-186) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 19 Jan 2006 07:11:42 +0000
parents 2d92f5c9d6ae ecfd9a69b670
children 5b7d410e31f9
comparison
equal deleted inserted replaced
90267:e5855ea89245 90268:d88caeac70d7
1 ;;; table.el --- create and edit WYSIWYG text based embedded tables 1 ;;; table.el --- create and edit WYSIWYG text based embedded tables
2 2
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc. 4 ;; 2005, 2006 Free Software Foundation, Inc.
5 5
6 ;; Keywords: wp, convenience 6 ;; Keywords: wp, convenience
7 ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com> 7 ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
8 ;; Created: Sat Jul 08 2000 13:28:45 (PST) 8 ;; Created: Sat Jul 08 2000 13:28:45 (PST)
9 ;; Revised: Sat Aug 06 2005 19:42:54 (CEST) 9 ;; Revised: Sat Aug 06 2005 19:42:54 (CEST)
619 ;;; 619 ;;;
620 ;;; Compatibility: 620 ;;; Compatibility:
621 ;;; 621 ;;;
622 622
623 ;; hush up the byte-compiler 623 ;; hush up the byte-compiler
624 (eval-when-compile 624 (defvar quail-translating)
625 (defvar quail-translating) 625 (defvar quail-converting)
626 (defvar quail-converting) 626 (defvar flyspell-mode)
627 (defvar flyspell-mode) 627 (defvar real-last-command)
628 (defvar real-last-command) 628 (defvar delete-selection-mode)
629 (defvar delete-selection-mode) 629 ;; This is evil!!
630 (unless (fboundp 'set-face-property) 630 ;; (eval-when-compile
631 (defun set-face-property (face prop value))) 631 ;; (unless (fboundp 'set-face-property)
632 (unless (fboundp 'unibyte-char-to-multibyte) 632 ;; (defun set-face-property (face prop value)))
633 (defun unibyte-char-to-multibyte (char))) 633 ;; (unless (fboundp 'unibyte-char-to-multibyte)
634 (defun table--point-in-cell-p (&optional location))) 634 ;; (defun unibyte-char-to-multibyte (char)))
635 ;; (defun table--point-in-cell-p (&optional location)))
635 636
636 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 637 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
637 ;;; 638 ;;;
638 ;;; Customization: 639 ;;; Customization:
639 ;;; 640 ;;;
908 (defvar table-inhibit-auto-fill-paragraph nil 909 (defvar table-inhibit-auto-fill-paragraph nil
909 "Non-nil inhibits auto fill paragraph when `table-with-cache-buffer' exits. 910 "Non-nil inhibits auto fill paragraph when `table-with-cache-buffer' exits.
910 This is always set to nil at the entry to `table-with-cache-buffer' before executing body forms.") 911 This is always set to nil at the entry to `table-with-cache-buffer' before executing body forms.")
911 (defvar table-mode-indicator nil 912 (defvar table-mode-indicator nil
912 "For mode line indicator") 913 "For mode line indicator")
913 (defvar table-fixed-mode-indicator nil 914 ;; This is not a real minor-mode but placed in the minor-mode-alist
914 "For mode line indicator") 915 ;; so that we can show the indicator on the mode line handy.
916 (make-variable-buffer-local table-mode-indicator)
917 (unless (assq table-mode-indicator minor-mode-alist)
918 (push '(table-mode-indicator (table-fixed-width-mode " Fixed-Table" " Table"))
919 minor-mode-alist))
920
915 (defconst table-source-languages '(html latex cals) 921 (defconst table-source-languages '(html latex cals)
916 "Supported source languages.") 922 "Supported source languages.")
917 (defvar table-source-info-plist nil 923 (defvar table-source-info-plist nil
918 "General storage for temporary information used while generating source.") 924 "General storage for temporary information used while generating source.")
919 ;;; These are not real minor-mode but placed in the minor-mode-alist 925
920 ;;; so that we can show the indicator on the mode line handy.
921 (mapcar (lambda (indicator)
922 (make-variable-buffer-local (car indicator))
923 (unless (assq (car indicator) minor-mode-alist)
924 (setq minor-mode-alist
925 (cons indicator minor-mode-alist))))
926 '((table-mode-indicator " Table")
927 (table-fixed-mode-indicator " Fixed-Table")))
928 ;;; The following history containers not only keep the history of user 926 ;;; The following history containers not only keep the history of user
929 ;;; entries but also serve as the default value providers. When an 927 ;;; entries but also serve as the default value providers. When an
930 ;;; interactive command is invoked it offers a user the latest entry 928 ;;; interactive command is invoked it offers a user the latest entry
931 ;;; of the history as a default selection. Therefore the values below 929 ;;; of the history as a default selection. Therefore the values below
932 ;;; are the first default value when a command is invoked for the very 930 ;;; are the first default value when a command is invoked for the very
1998 (let ((cell (table-recognize-cell 'force 'no-copy))) 1996 (let ((cell (table-recognize-cell 'force 'no-copy)))
1999 (if (and cell table-detect-cell-alignment) 1997 (if (and cell table-detect-cell-alignment)
2000 (table--detect-cell-alignment cell))) 1998 (table--detect-cell-alignment cell)))
2001 (unless (re-search-forward border end t) 1999 (unless (re-search-forward border end t)
2002 (goto-char end)))))))))) 2000 (goto-char end))))))))))
2003 (set-buffer-modified-p modified-flag))) 2001 (restore-buffer-modified-p modified-flag)))
2004 2002
2005 ;;;###autoload 2003 ;;;###autoload
2006 (defun table-unrecognize-region (beg end) 2004 (defun table-unrecognize-region (beg end)
2007 (interactive "r") 2005 (interactive "r")
2008 (table-recognize-region beg end -1)) 2006 (table-recognize-region beg end -1))
2088 (cdr cell)))) 2086 (cdr cell))))
2089 (save-current-buffer 2087 (save-current-buffer
2090 (set-buffer cache-buffer) 2088 (set-buffer cache-buffer)
2091 (erase-buffer) 2089 (erase-buffer)
2092 (table--insert-rectangle rectangle))))) 2090 (table--insert-rectangle rectangle)))))
2093 (set-buffer-modified-p modified-flag)) 2091 (restore-buffer-modified-p modified-flag))
2094 (if (featurep 'xemacs) 2092 (if (featurep 'xemacs)
2095 (table--warn-incompatibility)) 2093 (table--warn-incompatibility))
2096 cell))) 2094 cell)))
2097 2095
2098 ;;;###autoload 2096 ;;;###autoload
2927 (table--finish-delayed-tasks) 2925 (table--finish-delayed-tasks)
2928 (setq table-fixed-width-mode 2926 (setq table-fixed-width-mode
2929 (if (null arg) 2927 (if (null arg)
2930 (not table-fixed-width-mode) 2928 (not table-fixed-width-mode)
2931 (> (prefix-numeric-value arg) 0))) 2929 (> (prefix-numeric-value arg) 0)))
2932 (save-excursion
2933 (mapcar (lambda (buf)
2934 (set-buffer buf)
2935 (if (table--point-in-cell-p)
2936 (table--point-entered-cell-function)))
2937 (buffer-list)))
2938 (table--update-cell-face)) 2930 (table--update-cell-face))
2939 2931
2940 ;;;###autoload 2932 ;;;###autoload
2941 (defun table-query-dimension (&optional where) 2933 (defun table-query-dimension (&optional where)
2942 "Return the dimension of the current cell and the current table. 2934 "Return the dimension of the current cell and the current table.
4082 in a fixed width mode all cell width are fixed. When a word can not 4074 in a fixed width mode all cell width are fixed. When a word can not
4083 fit in the cell width the word is folded into the next line. The 4075 fit in the cell width the word is folded into the next line. The
4084 folded location is marked by a continuation character which is 4076 folded location is marked by a continuation character which is
4085 specified in the variable `table-word-continuation-char'. 4077 specified in the variable `table-word-continuation-char'.
4086 ") 4078 ")
4087 (print-help-return-message)))) 4079 (help-print-return-message))))
4088 4080
4089 (defun *table--cell-describe-bindings () 4081 (defun *table--cell-describe-bindings ()
4090 "Table cell version of `describe-bindings'." 4082 "Table cell version of `describe-bindings'."
4091 (interactive) 4083 (interactive)
4092 (if (not (table--point-in-cell-p)) 4084 (if (not (table--point-in-cell-p))
4100 (mapcar (lambda (binding) 4092 (mapcar (lambda (binding)
4101 (princ (format "%-16s%s\n" 4093 (princ (format "%-16s%s\n"
4102 (key-description (car binding)) 4094 (key-description (car binding))
4103 (cdr binding)))) 4095 (cdr binding))))
4104 table-cell-bindings) 4096 table-cell-bindings)
4105 (print-help-return-message)))) 4097 (help-print-return-message))))
4106 4098
4107 (defun *table--cell-dabbrev-expand (arg) 4099 (defun *table--cell-dabbrev-expand (arg)
4108 "Table cell version of `dabbrev-expand'." 4100 "Table cell version of `dabbrev-expand'."
4109 (interactive "*P") 4101 (interactive "*P")
4110 (let ((dabbrev-abbrev-char-regexp (concat "[^" 4102 (let ((dabbrev-abbrev-char-regexp (concat "[^"
4895 (if table-heighten-timer 4887 (if table-heighten-timer
4896 (table--update-cell-heightened 'now))) 4888 (table--update-cell-heightened 'now)))
4897 4889
4898 (defmacro table--log (&rest body) 4890 (defmacro table--log (&rest body)
4899 "Debug logging macro." 4891 "Debug logging macro."
4900 `(save-excursion 4892 `(with-current-buffer (get-buffer-create "log")
4901 (set-buffer (get-buffer-create "log"))
4902 (goto-char (point-min)) 4893 (goto-char (point-min))
4903 (let ((standard-output (current-buffer))) 4894 (let ((standard-output (current-buffer)))
4904 ,@body))) 4895 ,@body)))
4905 4896
4906 (defun table--measure-max-width (&optional unlimited) 4897 (defun table--measure-max-width (&optional unlimited)
4956 (let* ((cell (if first-only (prog1 cell-list (setq cell-list nil)) 4947 (let* ((cell (if first-only (prog1 cell-list (setq cell-list nil))
4957 (prog1 (car cell-list) (setq cell-list (cdr cell-list))))) 4948 (prog1 (car cell-list) (setq cell-list (cdr cell-list)))))
4958 (dig1-str (format "%1d" (prog1 (% count 10) (setq count (1+ count)))))) 4949 (dig1-str (format "%1d" (prog1 (% count 10) (setq count (1+ count))))))
4959 (goto-char (car cell)) 4950 (goto-char (car cell))
4960 (table-with-cache-buffer 4951 (table-with-cache-buffer
4961 (replace-regexp "." dig1-str) 4952 (while (re-search-forward "." nil t)
4953 (replace-match dig1-str nil nil))
4962 (setq table-inhibit-auto-fill-paragraph t)) 4954 (setq table-inhibit-auto-fill-paragraph t))
4963 (table--finish-delayed-tasks))) 4955 (table--finish-delayed-tasks)))
4964 (table--goto-coordinate current-coordinate))) 4956 (table--goto-coordinate current-coordinate)))
4965 4957
4966 (defun table--vertical-cell-list (&optional top-to-bottom first-only pivot internal-dir internal-list internal-px) 4958 (defun table--vertical-cell-list (&optional top-to-bottom first-only pivot internal-dir internal-list internal-px)
5338 (defun table--point-entered-cell-function (&optional old-point new-point) 5330 (defun table--point-entered-cell-function (&optional old-point new-point)
5339 "Point has entered a cell. 5331 "Point has entered a cell.
5340 Refresh the menu bar." 5332 Refresh the menu bar."
5341 (unless table-cell-entered-state 5333 (unless table-cell-entered-state
5342 (setq table-cell-entered-state t) 5334 (setq table-cell-entered-state t)
5343 (setq table-mode-indicator (not table-fixed-width-mode)) 5335 (setq table-mode-indicator t)
5344 (setq table-fixed-mode-indicator table-fixed-width-mode) 5336 (force-mode-line-update)
5345 (set-buffer-modified-p (buffer-modified-p))
5346 (table--warn-incompatibility) 5337 (table--warn-incompatibility)
5347 (run-hooks 'table-point-entered-cell-hook))) 5338 (run-hooks 'table-point-entered-cell-hook)))
5348 5339
5349 (defun table--point-left-cell-function (&optional old-point new-point) 5340 (defun table--point-left-cell-function (&optional old-point new-point)
5350 "Point has left a cell. 5341 "Point has left a cell.
5351 Refresh the menu bar." 5342 Refresh the menu bar."
5352 (when table-cell-entered-state 5343 (when table-cell-entered-state
5353 (setq table-cell-entered-state nil) 5344 (setq table-cell-entered-state nil)
5354 (setq table-mode-indicator nil) 5345 (setq table-mode-indicator nil)
5355 (setq table-fixed-mode-indicator nil) 5346 (force-mode-line-update)
5356 (set-buffer-modified-p (buffer-modified-p))
5357 (run-hooks 'table-point-left-cell-hook))) 5347 (run-hooks 'table-point-left-cell-hook)))
5358 5348
5359 (defun table--warn-incompatibility () 5349 (defun table--warn-incompatibility ()
5360 "If called from interactive operation warn the know incompatibilities. 5350 "If called from interactive operation warn the know incompatibilities.
5361 This feature is disabled when `table-disable-incompatibility-warning' 5351 This feature is disabled when `table-disable-incompatibility-warning'