aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/textmodes/table.el454
2 files changed, 204 insertions, 261 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f125aca980a..fe1bde3b45a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
12012-10-02 Stefan Monnier <monnier@iro.umontreal.ca> 12012-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * textmodes/table.el: Use lexical-binding, dolist, define-minor-mode.
4 (table-initialize-table-fixed-width-mode)
5 (table-set-table-fixed-width-mode): Remove functions.
6 (table-command-list): Move initialization into declaration.
7 (table--tweak-menu-for-xemacs): Move defun outside mapcar.
8 (table-with-cache-buffer): Use `declare'.
9 (table-span-cell): Simplify via CSE.
10 (table-fixed-width-mode): Use define-minor-mode.
11 (table-call-interactively, table-funcall, table-apply): Remove.
12 (table-function): New function, to replace them.
13
3 * bookmark.el (bookmark-search-pattern): Remove var. 14 * bookmark.el (bookmark-search-pattern): Remove var.
4 (bookmark-read-search-input): Remove function. 15 (bookmark-read-search-input): Remove function.
5 (bookmark-bmenu-search): Reimplement using a minibuffer. 16 (bookmark-bmenu-search): Reimplement using a minibuffer.
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 459e884d45d..3d9f88a43c9 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -1,4 +1,4 @@
1;;; table.el --- create and edit WYSIWYG text based embedded tables 1;;; table.el --- create and edit WYSIWYG text based embedded tables -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2000-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2000-2012 Free Software Foundation, Inc.
4 4
@@ -715,28 +715,6 @@ select a character that is unlikely to appear in your document."
715 :type 'character 715 :type 'character
716 :group 'table) 716 :group 'table)
717 717
718(defun table-set-table-fixed-width-mode (variable value)
719 (if (fboundp variable)
720 (funcall variable (if value 1 -1))))
721
722(defun table-initialize-table-fixed-width-mode (variable value)
723 (set variable value))
724
725(defcustom table-fixed-width-mode nil
726 "Cell width is fixed when this is non-nil.
727Normally it should be nil for allowing automatic cell width expansion
728that widens a cell when it is necessary. When non-nil, typing in a
729cell does not automatically expand the cell width. A word that is too
730long to fit in a cell is chopped into multiple lines. The chopped
731location is indicated by `table-word-continuation-char'. This
732variable's value can be toggled by \\[table-fixed-width-mode] at
733run-time."
734 :tag "Fix Cell Width"
735 :type 'boolean
736 :initialize 'table-initialize-table-fixed-width-mode
737 :set 'table-set-table-fixed-width-mode
738 :group 'table)
739
740(defcustom table-detect-cell-alignment t 718(defcustom table-detect-cell-alignment t
741 "Detect cell contents alignment automatically. 719 "Detect cell contents alignment automatically.
742When non-nil cell alignment is automatically determined by the 720When non-nil cell alignment is automatically determined by the
@@ -1001,14 +979,10 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu
1001 (dabbrev-completion . *table--cell-dabbrev-completion)) 979 (dabbrev-completion . *table--cell-dabbrev-completion))
1002 "List of cons cells consisting of (ORIGINAL-COMMAND . TABLE-VERSION-OF-THE-COMMAND).") 980 "List of cons cells consisting of (ORIGINAL-COMMAND . TABLE-VERSION-OF-THE-COMMAND).")
1003 981
1004(defvar table-command-list nil 982(defvar table-command-list
983 ;; Construct the real contents of the `table-command-list'.
984 (mapcar #'cdr table-command-remap-alist)
1005 "List of commands that override original commands.") 985 "List of commands that override original commands.")
1006;; construct the real contents of the `table-command-list'
1007(let ((remap-alist table-command-remap-alist))
1008 (setq table-command-list nil)
1009 (while remap-alist
1010 (setq table-command-list (cons (cdar remap-alist) table-command-list))
1011 (setq remap-alist (cdr remap-alist))))
1012 986
1013(defconst table-global-menu 987(defconst table-global-menu
1014 '("Table" 988 '("Table"
@@ -1241,18 +1215,17 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu
1241;; Unknown keywords should be quietly ignore so that future extension 1215;; Unknown keywords should be quietly ignore so that future extension
1242;; does not cause a problem in the old implementation. Sigh... 1216;; does not cause a problem in the old implementation. Sigh...
1243(when (featurep 'xemacs) 1217(when (featurep 'xemacs)
1244 (mapcar 1218 (defun table--tweak-menu-for-xemacs (menu)
1245 (defun table--tweak-menu-for-xemacs (menu)
1246 (cond 1219 (cond
1247 ((listp menu) 1220 ((listp menu)
1248 (mapcar 'table--tweak-menu-for-xemacs menu)) 1221 (mapcar #'table--tweak-menu-for-xemacs menu))
1249 ((vectorp menu) 1222 ((vectorp menu)
1250 (let ((i 0) (len (length menu))) 1223 (let ((len (length menu)))
1251 (while (< i len) 1224 (dotimes (i len)
1252 ;; replace :help with something harmless. 1225 ;; replace :help with something harmless.
1253 (if (eq (aref menu i) :help) (aset menu i :included)) 1226 (if (eq (aref menu i) :help) (aset menu i :included)))))))
1254 (setq i (1+ i))))))) 1227 (mapcar #'table--tweak-menu-for-xemacs
1255 (list table-global-menu table-cell-menu)) 1228 (list table-global-menu table-cell-menu))
1256 (defvar mark-active t)) 1229 (defvar mark-active t))
1257 1230
1258;; register table menu under global tools menu 1231;; register table menu under global tools menu
@@ -1286,6 +1259,7 @@ current buffer is restored to the original one. The last cache point
1286coordinate is stored in `table-cell-cache-point-coordinate'. The 1259coordinate is stored in `table-cell-cache-point-coordinate'. The
1287original buffer's point is moved to the location that corresponds to 1260original buffer's point is moved to the location that corresponds to
1288the last cache point coordinate." 1261the last cache point coordinate."
1262 (declare (debug (body)) (indent 0))
1289 (let ((height-expansion (make-symbol "height-expansion-var-symbol")) 1263 (let ((height-expansion (make-symbol "height-expansion-var-symbol"))
1290 (width-expansion (make-symbol "width-expansion-var-symbol"))) 1264 (width-expansion (make-symbol "width-expansion-var-symbol")))
1291 `(let (,height-expansion ,width-expansion) 1265 `(let (,height-expansion ,width-expansion)
@@ -1341,14 +1315,9 @@ the last cache point coordinate."
1341 ;; set up the update timer unless it is explicitly inhibited. 1315 ;; set up the update timer unless it is explicitly inhibited.
1342 (unless table-inhibit-update 1316 (unless table-inhibit-update
1343 (table--update-cell))))) 1317 (table--update-cell)))))
1344
1345;; for debugging the body form of the macro
1346(put 'table-with-cache-buffer 'edebug-form-spec '(body))
1347;; for neat presentation use the same indentation as `progn'
1348(put 'table-with-cache-buffer 'lisp-indent-function 0)
1349(if (or (featurep 'xemacs) 1318(if (or (featurep 'xemacs)
1350 (null (fboundp 'font-lock-add-keywords))) nil 1319 (null (fboundp 'font-lock-add-keywords))) nil
1351 ;; color it as a keyword 1320 ;; Color it as a keyword.
1352 (font-lock-add-keywords 1321 (font-lock-add-keywords
1353 'emacs-lisp-mode 1322 'emacs-lisp-mode
1354 '("\\<table-with-cache-buffer\\>"))) 1323 '("\\<table-with-cache-buffer\\>")))
@@ -1367,122 +1336,114 @@ the last cache point coordinate."
1367;; 1336;;
1368 1337
1369;; Point Motion Only Group 1338;; Point Motion Only Group
1370(mapc 1339(dolist (command
1371 (lambda (command) 1340 '(move-beginning-of-line
1372 (let ((func-symbol (intern (format "*table--cell-%s" command))) 1341 beginning-of-line
1373 (doc-string (format "Table remapped function for `%s'." command))) 1342 move-end-of-line
1374 (fset func-symbol 1343 end-of-line
1375 `(lambda 1344 beginning-of-buffer
1376 (&rest args) 1345 end-of-buffer
1377 ,doc-string 1346 forward-word
1378 (interactive) 1347 backward-word
1379 (let ((table-inhibit-update t) 1348 forward-sentence
1380 (deactivate-mark nil)) 1349 backward-sentence
1381 (table--finish-delayed-tasks) 1350 forward-paragraph
1382 (table-recognize-cell 'force) 1351 backward-paragraph))
1383 (table-with-cache-buffer 1352 (let ((func-symbol (intern (format "*table--cell-%s" command)))
1384 (call-interactively ',command) 1353 (doc-string (format "Table remapped function for `%s'." command)))
1385 (setq table-inhibit-auto-fill-paragraph t))))) 1354 (defalias func-symbol
1386 (setq table-command-remap-alist 1355 `(lambda
1387 (cons (cons command func-symbol) 1356 (&rest args)
1388 table-command-remap-alist)))) 1357 ,doc-string
1389 '(move-beginning-of-line 1358 (interactive)
1390 beginning-of-line 1359 (let ((table-inhibit-update t)
1391 move-end-of-line 1360 (deactivate-mark nil))
1392 end-of-line 1361 (table--finish-delayed-tasks)
1393 beginning-of-buffer 1362 (table-recognize-cell 'force)
1394 end-of-buffer 1363 (table-with-cache-buffer
1395 forward-word 1364 (call-interactively ',command)
1396 backward-word 1365 (setq table-inhibit-auto-fill-paragraph t)))))
1397 forward-sentence 1366 (push (cons command func-symbol)
1398 backward-sentence 1367 table-command-remap-alist)))
1399 forward-paragraph
1400 backward-paragraph))
1401 1368
1402;; Extraction Group 1369;; Extraction Group
1403(mapc 1370(dolist (command
1404 (lambda (command) 1371 '(kill-region
1405 (let ((func-symbol (intern (format "*table--cell-%s" command))) 1372 kill-ring-save
1406 (doc-string (format "Table remapped function for `%s'." command))) 1373 delete-region
1407 (fset func-symbol 1374 copy-region-as-kill
1408 `(lambda 1375 kill-line
1409 (&rest args) 1376 kill-word
1410 ,doc-string 1377 backward-kill-word
1411 (interactive) 1378 kill-sentence
1412 (table--finish-delayed-tasks) 1379 backward-kill-sentence
1413 (table-recognize-cell 'force) 1380 kill-paragraph
1414 (table-with-cache-buffer 1381 backward-kill-paragraph
1415 (table--remove-cell-properties (point-min) (point-max)) 1382 kill-sexp
1416 (table--remove-eol-spaces (point-min) (point-max)) 1383 backward-kill-sexp))
1417 (call-interactively ',command)) 1384 (let ((func-symbol (intern (format "*table--cell-%s" command)))
1418 (table--finish-delayed-tasks))) 1385 (doc-string (format "Table remapped function for `%s'." command)))
1419 (setq table-command-remap-alist 1386 (defalias func-symbol
1420 (cons (cons command func-symbol) 1387 `(lambda
1421 table-command-remap-alist)))) 1388 (&rest args)
1422 '(kill-region 1389 ,doc-string
1423 kill-ring-save 1390 (interactive)
1424 delete-region 1391 (table--finish-delayed-tasks)
1425 copy-region-as-kill 1392 (table-recognize-cell 'force)
1426 kill-line 1393 (table-with-cache-buffer
1427 kill-word 1394 (table--remove-cell-properties (point-min) (point-max))
1428 backward-kill-word 1395 (table--remove-eol-spaces (point-min) (point-max))
1429 kill-sentence 1396 (call-interactively ',command))
1430 backward-kill-sentence 1397 (table--finish-delayed-tasks)))
1431 kill-paragraph 1398 (push (cons command func-symbol)
1432 backward-kill-paragraph 1399 table-command-remap-alist)))
1433 kill-sexp
1434 backward-kill-sexp))
1435 1400
1436;; Pasting Group 1401;; Pasting Group
1437(mapc 1402(dolist (command
1438 (lambda (command) 1403 '(yank
1439 (let ((func-symbol (intern (format "*table--cell-%s" command))) 1404 clipboard-yank
1440 (doc-string (format "Table remapped function for `%s'." command))) 1405 yank-clipboard-selection
1441 (fset func-symbol 1406 insert))
1442 `(lambda 1407 (let ((func-symbol (intern (format "*table--cell-%s" command)))
1443 (&rest args) 1408 (doc-string (format "Table remapped function for `%s'." command)))
1444 ,doc-string 1409 (fset func-symbol
1445 (interactive) 1410 `(lambda
1446 (table--finish-delayed-tasks) 1411 (&rest args)
1447 (table-recognize-cell 'force) 1412 ,doc-string
1448 (table-with-cache-buffer 1413 (interactive)
1449 (call-interactively ',command) 1414 (table--finish-delayed-tasks)
1450 (table--untabify (point-min) (point-max)) 1415 (table-recognize-cell 'force)
1451 (table--fill-region (point-min) (point-max)) 1416 (table-with-cache-buffer
1452 (setq table-inhibit-auto-fill-paragraph t)) 1417 (call-interactively ',command)
1453 (table--finish-delayed-tasks))) 1418 (table--untabify (point-min) (point-max))
1454 (setq table-command-remap-alist 1419 (table--fill-region (point-min) (point-max))
1455 (cons (cons command func-symbol) 1420 (setq table-inhibit-auto-fill-paragraph t))
1456 table-command-remap-alist)))) 1421 (table--finish-delayed-tasks)))
1457 '(yank 1422 (push (cons command func-symbol)
1458 clipboard-yank 1423 table-command-remap-alist)))
1459 yank-clipboard-selection
1460 insert))
1461 1424
1462;; Formatting Group 1425;; Formatting Group
1463(mapc 1426(dolist (command
1464 (lambda (command) 1427 '(center-line
1465 (let ((func-symbol (intern (format "*table--cell-%s" command))) 1428 center-region
1466 (doc-string (format "Table remapped function for `%s'." command))) 1429 center-paragraph
1467 (fset func-symbol 1430 fill-paragraph))
1468 `(lambda 1431 (let ((func-symbol (intern (format "*table--cell-%s" command)))
1469 (&rest args) 1432 (doc-string (format "Table remapped function for `%s'." command)))
1470 ,doc-string 1433 (fset func-symbol
1471 (interactive) 1434 `(lambda
1472 (table--finish-delayed-tasks) 1435 (&rest args)
1473 (table-recognize-cell 'force) 1436 ,doc-string
1474 (table-with-cache-buffer 1437 (interactive)
1475 (let ((fill-column table-cell-info-width)) 1438 (table--finish-delayed-tasks)
1476 (call-interactively ',command)) 1439 (table-recognize-cell 'force)
1477 (setq table-inhibit-auto-fill-paragraph t)) 1440 (table-with-cache-buffer
1478 (table--finish-delayed-tasks))) 1441 (let ((fill-column table-cell-info-width))
1479 (setq table-command-remap-alist 1442 (call-interactively ',command))
1480 (cons (cons command func-symbol) 1443 (setq table-inhibit-auto-fill-paragraph t))
1481 table-command-remap-alist)))) 1444 (table--finish-delayed-tasks)))
1482 '(center-line 1445 (push (cons command func-symbol)
1483 center-region 1446 table-command-remap-alist)))
1484 center-paragraph
1485 fill-paragraph))
1486 1447
1487;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1448;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1488;; 1449;;
@@ -2581,7 +2542,7 @@ a negative argument ARG = -N means move forward N cells."
2581DIRECTION is one of symbols; right, left, above or below." 2542DIRECTION is one of symbols; right, left, above or below."
2582 (interactive 2543 (interactive
2583 (list 2544 (list
2584 (let* ((dummy (barf-if-buffer-read-only)) 2545 (let* ((_ (barf-if-buffer-read-only))
2585 (direction-list 2546 (direction-list
2586 (let* ((tmp (delete nil 2547 (let* ((tmp (delete nil
2587 (mapcar (lambda (d) 2548 (mapcar (lambda (d)
@@ -2605,40 +2566,35 @@ DIRECTION is one of symbols; right, left, above or below."
2605 (table-recognize-cell 'force) 2566 (table-recognize-cell 'force)
2606 (unless (table--cell-can-span-p direction) 2567 (unless (table--cell-can-span-p direction)
2607 (error "Can't span %s" (symbol-name direction))) 2568 (error "Can't span %s" (symbol-name direction)))
2608 ;; prepare beginning and ending positions of the border bar to strike through 2569 ;; Prepare beginning and end positions of the border bar to strike through.
2609 (let ((beg (cond 2570 (let ((beg (save-excursion
2610 ((eq direction 'right) 2571 (table--goto-coordinate
2611 (save-excursion 2572 (cond
2612 (table--goto-coordinate 2573 ((eq direction 'right)
2613 (cons (car table-cell-info-rb-coordinate) 2574 (cons (car table-cell-info-rb-coordinate)
2614 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension))) 2575 (1- (cdr table-cell-info-lu-coordinate))))
2615 ((eq direction 'below) 2576 ((eq direction 'below)
2616 (save-excursion
2617 (table--goto-coordinate
2618 (cons (1- (car table-cell-info-lu-coordinate)) 2577 (cons (1- (car table-cell-info-lu-coordinate))
2619 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension))) 2578 (1+ (cdr table-cell-info-rb-coordinate))))
2620 (t 2579 (t
2621 (save-excursion
2622 (table--goto-coordinate
2623 (cons (1- (car table-cell-info-lu-coordinate)) 2580 (cons (1- (car table-cell-info-lu-coordinate))
2624 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension))))) 2581 (1- (cdr table-cell-info-lu-coordinate)))))
2625 (end (cond 2582 'no-extension)))
2626 ((eq direction 'left) 2583 (end (save-excursion
2627 (save-excursion 2584 (table--goto-coordinate
2628 (table--goto-coordinate 2585 (cond
2586 ((eq direction 'left)
2629 (cons (car table-cell-info-lu-coordinate) 2587 (cons (car table-cell-info-lu-coordinate)
2630 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension))) 2588 (1+ (cdr table-cell-info-rb-coordinate))))
2631 ((eq direction 'above) 2589 ((eq direction 'above)
2632 (save-excursion
2633 (table--goto-coordinate
2634 (cons (1+ (car table-cell-info-rb-coordinate)) 2590 (cons (1+ (car table-cell-info-rb-coordinate))
2635 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension))) 2591 (1- (cdr table-cell-info-lu-coordinate))))
2636 (t 2592 (t
2637 (save-excursion
2638 (table--goto-coordinate
2639 (cons (1+ (car table-cell-info-rb-coordinate)) 2593 (cons (1+ (car table-cell-info-rb-coordinate))
2640 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension)))))) 2594 (1+ (cdr table-cell-info-rb-coordinate)))))
2641 ;; replace the bar with blank space while taking care of edges to be border or intersection 2595 'no-extension))))
2596 ;; Replace the bar with blank space while taking care of edges to be border
2597 ;; or intersection.
2642 (save-excursion 2598 (save-excursion
2643 (goto-char beg) 2599 (goto-char beg)
2644 (if (memq direction '(left right)) 2600 (if (memq direction '(left right))
@@ -2832,7 +2788,7 @@ Creates a cell on the left and a cell on the right of the current point location
2832ORIENTATION is a symbol either horizontally or vertically." 2788ORIENTATION is a symbol either horizontally or vertically."
2833 (interactive 2789 (interactive
2834 (list 2790 (list
2835 (let* ((dummy (barf-if-buffer-read-only)) 2791 (let* ((_ (barf-if-buffer-read-only))
2836 (completion-ignore-case t) 2792 (completion-ignore-case t)
2837 (default (car table-cell-split-orientation-history))) 2793 (default (car table-cell-split-orientation-history)))
2838 (intern (downcase (completing-read 2794 (intern (downcase (completing-read
@@ -2852,7 +2808,7 @@ ORIENTATION is a symbol either horizontally or vertically."
2852WHAT is a symbol 'cell, 'row or 'column. JUSTIFY is a symbol 'left, 2808WHAT is a symbol 'cell, 'row or 'column. JUSTIFY is a symbol 'left,
2853'center, 'right, 'top, 'middle, 'bottom or 'none." 2809'center, 'right, 'top, 'middle, 'bottom or 'none."
2854 (interactive 2810 (interactive
2855 (list (let* ((dummy (barf-if-buffer-read-only)) 2811 (list (let* ((_ (barf-if-buffer-read-only))
2856 (completion-ignore-case t) 2812 (completion-ignore-case t)
2857 (default (car table-target-history))) 2813 (default (car table-target-history)))
2858 (intern (downcase (completing-read 2814 (intern (downcase (completing-read
@@ -2910,17 +2866,18 @@ JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
2910 (table--justify-cell-contents justify)))))) 2866 (table--justify-cell-contents justify))))))
2911 2867
2912;;;###autoload 2868;;;###autoload
2913(defun table-fixed-width-mode (&optional arg) 2869(define-minor-mode table-fixed-width-mode
2914 "Toggle fixing width mode. 2870 "Cell width is fixed when this is non-nil.
2915In the fixed width mode, typing inside a cell never changes the cell 2871Normally it should be nil for allowing automatic cell width expansion
2916width where in the normal mode the cell width expands automatically in 2872that widens a cell when it is necessary. When non-nil, typing in a
2917order to prevent a word being folded into multiple lines." 2873cell does not automatically expand the cell width. A word that is too
2918 (interactive "P") 2874long to fit in a cell is chopped into multiple lines. The chopped
2875location is indicated by `table-word-continuation-char'. This
2876variable's value can be toggled by \\[table-fixed-width-mode] at
2877run-time."
2878 :tag "Fix Cell Width"
2879 :group 'table
2919 (table--finish-delayed-tasks) 2880 (table--finish-delayed-tasks)
2920 (setq table-fixed-width-mode
2921 (if (null arg)
2922 (not table-fixed-width-mode)
2923 (> (prefix-numeric-value arg) 0)))
2924 (table--update-cell-face)) 2881 (table--update-cell-face))
2925 2882
2926;;;###autoload 2883;;;###autoload
@@ -3004,7 +2961,7 @@ CALS (DocBook DTD):
3004 URL `http://www.oreilly.com/catalog/docbook/chapter/book/table.html#AEN114751' 2961 URL `http://www.oreilly.com/catalog/docbook/chapter/book/table.html#AEN114751'
3005" 2962"
3006 (interactive 2963 (interactive
3007 (let* ((dummy (unless (table--probe-cell) (error "Table not found here"))) 2964 (let* ((_ (unless (table--probe-cell) (error "Table not found here")))
3008 (completion-ignore-case t) 2965 (completion-ignore-case t)
3009 (default (car table-source-language-history)) 2966 (default (car table-source-language-history))
3010 (language (downcase (completing-read 2967 (language (downcase (completing-read
@@ -3093,7 +3050,7 @@ CALS (DocBook DTD):
3093 ))) 3050 )))
3094 dest-buffer)) 3051 dest-buffer))
3095 3052
3096(defun table--generate-source-prologue (dest-buffer language caption col-list row-list) 3053(defun table--generate-source-prologue (dest-buffer language caption col-list _row-list)
3097 "Generate and insert source prologue into DEST-BUFFER." 3054 "Generate and insert source prologue into DEST-BUFFER."
3098 (with-current-buffer dest-buffer 3055 (with-current-buffer dest-buffer
3099 (cond 3056 (cond
@@ -3121,7 +3078,7 @@ CALS (DocBook DTD):
3121 (insert (format " <%s valign=\"top\">\n" (table-get-source-info 'row-type)))) 3078 (insert (format " <%s valign=\"top\">\n" (table-get-source-info 'row-type))))
3122 ))) 3079 )))
3123 3080
3124(defun table--generate-source-epilogue (dest-buffer language col-list row-list) 3081(defun table--generate-source-epilogue (dest-buffer language _col-list _row-list)
3125 "Generate and insert source epilogue into DEST-BUFFER." 3082 "Generate and insert source epilogue into DEST-BUFFER."
3126 (with-current-buffer dest-buffer 3083 (with-current-buffer dest-buffer
3127 (cond 3084 (cond
@@ -3133,14 +3090,12 @@ CALS (DocBook DTD):
3133 (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; insert before 3090 (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; insert before
3134 (save-excursion 3091 (save-excursion
3135 (goto-char (table-get-source-info 'colspec-marker)) 3092 (goto-char (table-get-source-info 'colspec-marker))
3136 (mapc 3093 (dolist (col (sort (table-get-source-info 'colnum-list) '<))
3137 (lambda (col) 3094 (insert (format " <colspec colnum=\"%d\" colname=\"c%d\"/>\n" col col))))
3138 (insert (format " <colspec colnum=\"%d\" colname=\"c%d\"/>\n" col col)))
3139 (sort (table-get-source-info 'colnum-list) '<)))
3140 (insert (format " </%s>\n </tgroup>\n</table>\n" (table-get-source-info 'row-type)))) 3095 (insert (format " </%s>\n </tgroup>\n</table>\n" (table-get-source-info 'row-type))))
3141 ))) 3096 )))
3142 3097
3143(defun table--generate-source-scan-rows (dest-buffer language origin-cell col-list row-list) 3098(defun table--generate-source-scan-rows (dest-buffer language _origin-cell col-list row-list)
3144 "Generate and insert source rows into DEST-BUFFER." 3099 "Generate and insert source rows into DEST-BUFFER."
3145 (table-put-source-info 'current-row 1) 3100 (table-put-source-info 'current-row 1)
3146 (while row-list 3101 (while row-list
@@ -3286,7 +3241,7 @@ CALS (DocBook DTD):
3286 "Test if character C is one of the horizontal characters" 3241 "Test if character C is one of the horizontal characters"
3287 (memq c (string-to-list table-cell-horizontal-chars))) 3242 (memq c (string-to-list table-cell-horizontal-chars)))
3288 3243
3289(defun table--generate-source-scan-lines (dest-buffer language origin-cell tail-cell col-list row-list) 3244(defun table--generate-source-scan-lines (dest-buffer _language origin-cell tail-cell col-list row-list)
3290 "Scan the table line by line. 3245 "Scan the table line by line.
3291Currently this method is for LaTeX only." 3246Currently this method is for LaTeX only."
3292 (let* ((lu-coord (table--get-coordinate (car origin-cell))) 3247 (let* ((lu-coord (table--get-coordinate (car origin-cell)))
@@ -3403,8 +3358,7 @@ Example:
3403 (table-insert 16 8 5 1) 3358 (table-insert 16 8 5 1)
3404 (table-insert-sequence \"@\" 0 1 2 'right) 3359 (table-insert-sequence \"@\" 0 1 2 'right)
3405 (table-forward-cell 1) 3360 (table-forward-cell 1)
3406 (table-insert-sequence \"64\" 0 1 2 'left)) 3361 (table-insert-sequence \"64\" 0 1 2 'left))"
3407"
3408 (interactive 3362 (interactive
3409 (progn 3363 (progn
3410 (barf-if-buffer-read-only) 3364 (barf-if-buffer-read-only)
@@ -3896,36 +3850,34 @@ converts a table into plain text without frames. It is a companion to
3896 3850
3897(defun table--make-cell-map () 3851(defun table--make-cell-map ()
3898 "Make the table cell keymap if it does not exist yet." 3852 "Make the table cell keymap if it does not exist yet."
3899 ;; this is irrelevant to keymap but good place to make sure to be executed 3853 ;; This is irrelevant to keymap but good place to make sure to be executed.
3900 (table--update-cell-face) 3854 (table--update-cell-face)
3901 (unless table-cell-map 3855 (unless table-cell-map
3902 (let ((map (make-sparse-keymap)) 3856 (let ((map (make-sparse-keymap)))
3903 (remap-alist table-command-remap-alist)) 3857 ;; `table-command-prefix' mode specific bindings.
3904 ;; table-command-prefix mode specific bindings
3905 (if (vectorp table-command-prefix) 3858 (if (vectorp table-command-prefix)
3906 (mapc (lambda (binding) 3859 (dolist (binding table-cell-bindings)
3907 (let ((seq (copy-sequence (car binding)))) 3860 (let ((seq (copy-sequence (car binding))))
3908 (and (vectorp seq) 3861 (and (vectorp seq)
3909 (listp (aref seq 0)) 3862 (listp (aref seq 0))
3910 (eq (car (aref seq 0)) 'control) 3863 (eq (car (aref seq 0)) 'control)
3911 (progn 3864 (progn
3912 (aset seq 0 (cadr (aref seq 0))) 3865 (aset seq 0 (cadr (aref seq 0)))
3913 (define-key map (vconcat table-command-prefix seq) (cdr binding)))))) 3866 (define-key map (vconcat table-command-prefix seq)
3914 table-cell-bindings)) 3867 (cdr binding)))))))
3915 ;; shorthand control bindings 3868 ;; Shorthand control bindings.
3916 (mapc (lambda (binding) 3869 (dolist (binding table-cell-bindings)
3917 (define-key map (car binding) (cdr binding))) 3870 (define-key map (car binding) (cdr binding)))
3918 table-cell-bindings) 3871 ;; Remap normal commands to table specific version.
3919 ;; remap normal commands to table specific version 3872 (dolist (remap table-command-remap-alist)
3920 (while remap-alist 3873 (define-key map (vector 'remap (car remap)) (cdr remap)))
3921 (define-key map (vector 'remap (caar remap-alist)) (cdar remap-alist))
3922 (setq remap-alist (cdr remap-alist)))
3923 ;; 3874 ;;
3924 (setq table-cell-map map) 3875 (setq table-cell-map map)
3925 (fset 'table-cell-map map))) 3876 (fset 'table-cell-map map)))
3926 ;; add menu for table cells 3877 ;; Add menu for table cells.
3927 (unless table-disable-menu 3878 (unless table-disable-menu
3928 (easy-menu-define table-cell-menu-map table-cell-map "Table cell menu" table-cell-menu) 3879 (easy-menu-define table-cell-menu-map table-cell-map
3880 "Table cell menu" table-cell-menu)
3929 (if (featurep 'xemacs) 3881 (if (featurep 'xemacs)
3930 (easy-menu-add table-cell-menu))) 3882 (easy-menu-add table-cell-menu)))
3931 (run-hooks 'table-cell-map-hook)) 3883 (run-hooks 'table-cell-map-hook))
@@ -4092,6 +4044,8 @@ key binding
4092 table-cell-bindings) 4044 table-cell-bindings)
4093 (help-print-return-message)))) 4045 (help-print-return-message))))
4094 4046
4047(defvar dabbrev-abbrev-char-regexp)
4048
4095(defun *table--cell-dabbrev-expand (arg) 4049(defun *table--cell-dabbrev-expand (arg)
4096 "Table cell version of `dabbrev-expand'." 4050 "Table cell version of `dabbrev-expand'."
4097 (interactive "*P") 4051 (interactive "*P")
@@ -4291,38 +4245,16 @@ cache buffer into the designated cell in the table buffer."
4291 (car (table--get-coordinate (cdr (table--horizontal-cell-list nil t)))) 4245 (car (table--get-coordinate (cdr (table--horizontal-cell-list nil t))))
4292 (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t)))))))) 4246 (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))))
4293 4247
4294(defun table-call-interactively (function &optional record-flag keys) 4248(defun table-function (function)
4295 "Call FUNCTION, or a table version of it if applicable. 4249 ;; FIXME: Apparently unused. There used to be table-funcall, table-apply,
4296See `call-interactively' for full description of the arguments." 4250 ;; and table-call-interactively instead, neither of which seemed to be
4297 (let ((table-func (intern-soft (format "*table--cell-%s" function)))) 4251 ;; used either.
4298 (call-interactively 4252 "Return FUNCTION, or a table version of it if applicable."
4299 (if (and table-func
4300 (table--point-in-cell-p))
4301 table-func
4302 function) record-flag keys)))
4303
4304(defun table-funcall (function &rest arguments)
4305 "Call FUNCTION, or a table version of it if applicable.
4306See `funcall' for full description of the arguments."
4307 (let ((table-func (intern-soft (format "*table--cell-%s" function)))) 4253 (let ((table-func (intern-soft (format "*table--cell-%s" function))))
4308 (apply 4254 (if (and table-func
4309 (if (and table-func
4310 (table--point-in-cell-p)) 4255 (table--point-in-cell-p))
4311 table-func 4256 table-func
4312 function) 4257 function)))
4313 arguments)))
4314
4315(defmacro table-apply (function &rest arguments)
4316 "Call FUNCTION, or a table version of it if applicable.
4317See `apply' for full description of the arguments."
4318 (let ((table-func (make-symbol "table-func")))
4319 `(let ((,table-func (intern-soft (format "*table--cell-%s" ,function))))
4320 (apply
4321 (if (and ,table-func
4322 (table--point-in-cell-p))
4323 ,table-func
4324 ,function)
4325 ,@arguments))))
4326 4258
4327;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 4259;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4328;; 4260;;
@@ -5124,7 +5056,7 @@ Focus only on the corner pattern. Further cell validity check is required."
5124 (throw 'retry-vertical nil)) 5056 (throw 'retry-vertical nil))
5125 (t (throw 'retry-horizontal nil))))))))))))) 5057 (t (throw 'retry-horizontal nil)))))))))))))
5126 5058
5127(defun table--editable-cell-p (&optional abort-on-error) 5059(defun table--editable-cell-p (&optional _abort-on-error)
5128 (and (not buffer-read-only) 5060 (and (not buffer-read-only)
5129 (get-text-property (point) 'table-cell))) 5061 (get-text-property (point) 'table-cell)))
5130 5062
@@ -5310,7 +5242,7 @@ instead of the current buffer and returns the OBJECT."
5310 "Put cell's vertical alignment property." 5242 "Put cell's vertical alignment property."
5311 (table--put-property cell 'table-valign valign)) 5243 (table--put-property cell 'table-valign valign))
5312 5244
5313(defun table--point-entered-cell-function (&optional old-point new-point) 5245(defun table--point-entered-cell-function (&optional _old-point _new-point)
5314 "Point has entered a cell. 5246 "Point has entered a cell.
5315Refresh the menu bar." 5247Refresh the menu bar."
5316 ;; Avoid calling point-motion-hooks recursively. 5248 ;; Avoid calling point-motion-hooks recursively.
@@ -5322,7 +5254,7 @@ Refresh the menu bar."
5322 (table--warn-incompatibility) 5254 (table--warn-incompatibility)
5323 (run-hooks 'table-point-entered-cell-hook)))) 5255 (run-hooks 'table-point-entered-cell-hook))))
5324 5256
5325(defun table--point-left-cell-function (&optional old-point new-point) 5257(defun table--point-left-cell-function (&optional _old-point _new-point)
5326 "Point has left a cell. 5258 "Point has left a cell.
5327Refresh the menu bar." 5259Refresh the menu bar."
5328 ;; Avoid calling point-motion-hooks recursively. 5260 ;; Avoid calling point-motion-hooks recursively.