emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/table.el


From: Juanma Barranquero
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/table.el
Date: Thu, 05 Jun 2003 16:03:55 -0400

Index: emacs/lisp/textmodes/table.el
diff -c emacs/lisp/textmodes/table.el:1.5 emacs/lisp/textmodes/table.el:1.6
*** emacs/lisp/textmodes/table.el:1.5   Tue Feb 18 06:17:11 2003
--- emacs/lisp/textmodes/table.el       Thu Jun  5 16:03:54 2003
***************
*** 5,11 ****
  ;; Keywords: wp, convenience
  ;; Author: Takaaki Ota <address@hidden>
  ;; Created: Sat Jul 08 2000 13:28:45 (PST)
! ;; Revised: mar feb 18 2003 10:03:18 (Romance Standard Time)
  
  ;; This file is part of GNU Emacs.
  
--- 5,11 ----
  ;; Keywords: wp, convenience
  ;; Author: Takaaki Ota <address@hidden>
  ;; Created: Sat Jul 08 2000 13:28:45 (PST)
! ;; Revised: jue jun 05 2003 22:00:02 (Hora de verano romance)
  
  ;; This file is part of GNU Emacs.
  
***************
*** 688,697 ****
    :tag "Cell Face"
    :group 'table)
  
! (defcustom table-cell-horizontal-char ?\-
!   "*Character that forms table cell's horizontal border line."
!   :tag "Cell Horizontal Boundary Character"
!   :type 'character
    :group 'table)
  
  (defcustom table-cell-vertical-char ?\|
--- 688,697 ----
    :tag "Cell Face"
    :group 'table)
  
! (defcustom table-cell-horizontal-chars "-="
!   "*Characters that may be used for table cell's horizontal border line."
!   :tag "Cell Horizontal Boundary Characters"
!   :type 'string
    :group 'table)
  
  (defcustom table-cell-vertical-char ?\|
***************
*** 986,992 ****
      )
    "Bindings for table cell commands.")
  
! (defconst table-command-remap-alist
    '((self-insert-command . *table--cell-self-insert-command)
      (completion-separator-self-insert-autofilling . 
*table--cell-self-insert-command)
      (completion-separator-self-insert-command . 
*table--cell-self-insert-command)
--- 986,992 ----
      )
    "Bindings for table cell commands.")
  
! (defvar table-command-remap-alist
    '((self-insert-command . *table--cell-self-insert-command)
      (completion-separator-self-insert-autofilling . 
*table--cell-self-insert-command)
      (completion-separator-self-insert-command . 
*table--cell-self-insert-command)
***************
*** 1004,1010 ****
      (dabbrev-completion . *table--cell-dabbrev-completion))
    "List of cons cells consisting of (ORIGINAL-COMMAND . 
TABLE-VERSION-OF-THE-COMMAND).")
  
! (defconst table-command-list nil
    "List of commands that override original commands.")
  ;; construct the real contents of the `table-command-list'
  (let ((remap-alist table-command-remap-alist))
--- 1004,1010 ----
      (dabbrev-completion . *table--cell-dabbrev-completion))
    "List of cons cells consisting of (ORIGINAL-COMMAND . 
TABLE-VERSION-OF-THE-COMMAND).")
  
! (defvar table-command-list nil
    "List of commands that override original commands.")
  ;; construct the real contents of the `table-command-list'
  (let ((remap-alist table-command-remap-alist))
***************
*** 1658,1664 ****
        (setq cw cell-width)
        (setq i 0)
        (while (< i columns)
!       (insert (make-string (car cw) table-cell-horizontal-char) 
table-cell-intersection-char)
        (if (cdr cw) (setq cw (cdr cw)))
        (setq i (1+ i)))
        (setq border-str (buffer-substring (point-min) (point-max)))
--- 1658,1664 ----
        (setq cw cell-width)
        (setq i 0)
        (while (< i columns)
!       (insert (make-string (car cw) (string-to-char 
table-cell-horizontal-chars)) table-cell-intersection-char)
        (if (cdr cw) (setq cw (cdr cw)))
        (setq i (1+ i)))
        (setq border-str (buffer-substring (point-min) (point-max)))
***************
*** 1748,1754 ****
          (while (> i 0)
            (setq rect (cons
                        (concat (if exclude-left "" (char-to-string 
table-cell-intersection-char))
!                               (make-string (- (cadr this) (caar this)) 
table-cell-horizontal-char)
                                (if exclude-right "" (char-to-string 
table-cell-intersection-char)))
                        rect))
            (let ((j cell-height))
--- 1748,1754 ----
          (while (> i 0)
            (setq rect (cons
                        (concat (if exclude-left "" (char-to-string 
table-cell-intersection-char))
!                               (make-string (- (cadr this) (caar this)) 
(string-to-char table-cell-horizontal-chars))
                                (if exclude-right "" (char-to-string 
table-cell-intersection-char)))
                        rect))
            (let ((j cell-height))
***************
*** 1801,1807 ****
         (coord-list (table--cell-list-to-coord-list (table--vertical-cell-list 
t nil 'left)))
         (append-column (if coord-list nil (setq coord-list 
(table--find-row-column 'column))))
         (cell-width (car (table--min-coord-list coord-list)))
!        (border-str (table--multiply-string (concat (make-string cell-width 
table-cell-horizontal-char)
                                                     (char-to-string 
table-cell-intersection-char)) n))
         (cell-str (table--multiply-string (concat (table--cell-blank-str 
cell-width)
                                                   (let ((str (string 
table-cell-vertical-char)))
--- 1801,1807 ----
         (coord-list (table--cell-list-to-coord-list (table--vertical-cell-list 
t nil 'left)))
         (append-column (if coord-list nil (setq coord-list 
(table--find-row-column 'column))))
         (cell-width (car (table--min-coord-list coord-list)))
!        (border-str (table--multiply-string (concat (make-string cell-width 
(string-to-char table-cell-horizontal-chars))
                                                     (char-to-string 
table-cell-intersection-char)) n))
         (cell-str (table--multiply-string (concat (table--cell-blank-str 
cell-width)
                                                   (let ((str (string 
table-cell-vertical-char)))
***************
*** 1915,1927 ****
      (if (>= arg 0)
        (save-excursion
          (goto-char (point-min))
!         (let* ((border (format "[%c%c%c]"
!                                table-cell-horizontal-char
                                 table-cell-vertical-char
                                 table-cell-intersection-char))
                 (border3 (concat border border border))
!                (non-border (format "^[^%c%c%c]*$"
!                                    table-cell-horizontal-char
                                     table-cell-vertical-char
                                     table-cell-intersection-char)))
            ;; `table-recognize-region' is an expensive function so minimize
--- 1915,1927 ----
      (if (>= arg 0)
        (save-excursion
          (goto-char (point-min))
!         (let* ((border (format "[%s%c%c]"
!                                table-cell-horizontal-chars
                                 table-cell-vertical-char
                                 table-cell-intersection-char))
                 (border3 (concat border border border))
!                (non-border (format "^[^%s%c%c]*$"
!                                    table-cell-horizontal-chars
                                     table-cell-vertical-char
                                     table-cell-intersection-char)))
            ;; `table-recognize-region' is an expensive function so minimize
***************
*** 1964,1975 ****
        (table--remove-cell-properties beg end)
        (save-excursion
        (goto-char beg)
!       (let* ((border (format "[%c%c%c]"
!                              table-cell-horizontal-char
                               table-cell-vertical-char
                               table-cell-intersection-char))
!              (non-border (format "[^%c%c%c]"
!                                  table-cell-horizontal-char
                                   table-cell-vertical-char
                                   table-cell-intersection-char))
               (inhibit-read-only t))
--- 1964,1975 ----
        (table--remove-cell-properties beg end)
        (save-excursion
        (goto-char beg)
!       (let* ((border (format "[%s%c%c]"
!                              table-cell-horizontal-chars
                               table-cell-vertical-char
                               table-cell-intersection-char))
!              (non-border (format "[^%s%c%c]"
!                                  table-cell-horizontal-chars
                                   table-cell-vertical-char
                                   table-cell-intersection-char))
               (inhibit-read-only t))
***************
*** 2318,2335 ****
                               (1+ (cdr (cdr this)))
                             (cdr (cdr this))))))
               (tmp (extract-rectangle (1- beg) end))
!              (border (format "[%c%c]\\%c"
!                              table-cell-horizontal-char
                               table-cell-intersection-char
                               table-cell-intersection-char))
               (blank (table--cell-blank-str))
               rectangle)
          ;; create a single wide vertical bar of empty cell fragment
          (while tmp
!           (setq rectangle (cons (if (string-match border (car tmp))
!                                     (string table-cell-horizontal-char)
                                    blank)
                                  rectangle))
            (setq tmp (cdr tmp)))
          (setq rectangle (nreverse rectangle))
          ;; untabify the area right of the bar that is about to be inserted
--- 2318,2338 ----
                               (1+ (cdr (cdr this)))
                             (cdr (cdr this))))))
               (tmp (extract-rectangle (1- beg) end))
!              (border (format "[%s%c]\\%c"
!                              table-cell-horizontal-chars
                               table-cell-intersection-char
                               table-cell-intersection-char))
               (blank (table--cell-blank-str))
               rectangle)
          ;; create a single wide vertical bar of empty cell fragment
          (while tmp
! ;        (message "tmp is %s" tmp)
!           (setq rectangle (cons
!                          (if (string-match border (car tmp))
!                                     (substring (car tmp) 0 1)
                                    blank)
                                  rectangle))
+ ;        (message "rectangle is %s" rectangle)
            (setq tmp (cdr tmp)))
          (setq rectangle (nreverse rectangle))
          ;; untabify the area right of the bar that is about to be inserted
***************
*** 2656,2662 ****
            (setq rectangle
                  (cons (if below-contp
                            (char-to-string table-cell-intersection-char)
!                         (char-to-string table-cell-horizontal-char))
                        rectangle))
            (while (> n-element 0)
              (setq rectangle (cons (table--cell-blank-str 1) rectangle))
--- 2659,2665 ----
            (setq rectangle
                  (cons (if below-contp
                            (char-to-string table-cell-intersection-char)
!                         (substring table-cell-horizontal-chars 0 1))
                        rectangle))
            (while (> n-element 0)
              (setq rectangle (cons (table--cell-blank-str 1) rectangle))
***************
*** 2664,2670 ****
            (setq rectangle
                  (cons (if above-contp
                            (char-to-string table-cell-intersection-char)
!                         (char-to-string table-cell-horizontal-char))
                        rectangle))
            (delete-rectangle beg end)
            (goto-char beg)
--- 2667,2673 ----
            (setq rectangle
                  (cons (if above-contp
                            (char-to-string table-cell-intersection-char)
!                         (substring table-cell-horizontal-chars 0 1))
                        rectangle))
            (delete-rectangle beg end)
            (goto-char beg)
***************
*** 2673,2683 ****
        (insert (if (and (> (point) (point-min))
                         (save-excursion
                           (forward-char -1)
!                          (looking-at (regexp-quote (char-to-string 
table-cell-horizontal-char)))))
                    table-cell-intersection-char
                  table-cell-vertical-char)
                (table--cell-blank-str (- end beg 2))
!               (if (looking-at (regexp-quote (char-to-string 
table-cell-horizontal-char)))
                    table-cell-intersection-char
                  table-cell-vertical-char))))
      ;; recognize the newly created spanned cell
--- 2676,2688 ----
        (insert (if (and (> (point) (point-min))
                         (save-excursion
                           (forward-char -1)
!                          (looking-at (regexp-opt-charset
!                                       (string-to-list 
table-cell-horizontal-chars)))))
                    table-cell-intersection-char
                  table-cell-vertical-char)
                (table--cell-blank-str (- end beg 2))
!               (if (looking-at (regexp-opt-charset
!                                (string-to-list table-cell-horizontal-chars)))
                    table-cell-intersection-char
                  table-cell-vertical-char))))
      ;; recognize the newly created spanned cell
***************
*** 2711,2717 ****
        (goto-char beg)
        (delete-region beg end)
        (insert table-cell-intersection-char
!             (make-string table-cell-info-width table-cell-horizontal-char)
              table-cell-intersection-char)
        (table--goto-coordinate old-coordinate)
        (forward-line 1)
--- 2716,2722 ----
        (goto-char beg)
        (delete-region beg end)
        (insert table-cell-intersection-char
!             (make-string table-cell-info-width (string-to-char 
table-cell-horizontal-chars))
              table-cell-intersection-char)
        (table--goto-coordinate old-coordinate)
        (forward-line 1)
***************
*** 3284,3289 ****
--- 3289,3298 ----
                         ((eq language 'cals) 10)))
        (insert ?\n)))))
  
+ (defun table--cell-horizontal-char-p (c)
+   "Test if character C is one of the horizontal characters"
+   (memq c (string-to-list table-cell-horizontal-chars)))
+ 
  (defun table--generate-source-scan-lines (dest-buffer language origin-cell 
tail-cell col-list row-list)
    "Scan the table line by line.
  Currently this method is for LaTeX only."
***************
*** 3303,3320 ****
             start i c)
        (if border-p
            ;; horizontal cell border processing
!           (if (and (eq (car border-char-list) table-cell-horizontal-char)
                     (table--uniform-list-p border-char-list))
                (with-current-buffer dest-buffer
                  (insert "\\hline\n"))
              (setq i 0)
              (while (setq c (nth i border-char-list))
!               (if (and start (not (eq c table-cell-horizontal-char)))
                    (progn
                      (with-current-buffer dest-buffer
                        (insert (format "\\cline{%d-%d}\n" (1+ start) i)))
                      (setq start nil)))
!               (if (and (not start) (eq c table-cell-horizontal-char))
                    (setq start i))
                (setq i (1+ i)))
              (if start
--- 3312,3329 ----
             start i c)
        (if border-p
            ;; horizontal cell border processing
!           (if (and (table--cell-horizontal-char-p (car border-char-list))
                     (table--uniform-list-p border-char-list))
                (with-current-buffer dest-buffer
                  (insert "\\hline\n"))
              (setq i 0)
              (while (setq c (nth i border-char-list))
!               (if (and start (not (table--cell-horizontal-char-p c)))
                    (progn
                      (with-current-buffer dest-buffer
                        (insert (format "\\cline{%d-%d}\n" (1+ start) i)))
                      (setq start nil)))
!               (if (and (not start) (table--cell-horizontal-char-p c))
                    (setq start i))
                (setq i (1+ i)))
              (if start
***************
*** 3534,3540 ****
              (delete-char 1)
              (insert table-cell-intersection-char))
          (delete-char 1)
!         (insert table-cell-horizontal-char))
        (setq n (1- n))
        (setcar coord (1+ (car coord)))))
      ;; goto appropriate end point
--- 3543,3549 ----
              (delete-char 1)
              (insert table-cell-intersection-char))
          (delete-char 1)
!         (insert (string-to-char table-cell-horizontal-chars)))
        (setq n (1- n))
        (setcar coord (1+ (car coord)))))
      ;; goto appropriate end point
***************
*** 3576,3584 ****
        (table--goto-coordinate coord)
        (if (save-excursion
              (or (and (table--goto-coordinate (cons (1- (car coord)) (cdr 
coord)) 'no-extension)
!                      (looking-at (regexp-quote (char-to-string 
table-cell-horizontal-char))))
                  (and (table--goto-coordinate (cons (1+ (car coord)) (cdr 
coord)) 'no-extension)
!                      (looking-at (regexp-quote (char-to-string 
table-cell-horizontal-char))))))
            (progn
              (delete-char 1)
              (insert table-cell-intersection-char))
--- 3585,3595 ----
        (table--goto-coordinate coord)
        (if (save-excursion
              (or (and (table--goto-coordinate (cons (1- (car coord)) (cdr 
coord)) 'no-extension)
!                      (looking-at (regexp-opt-charset
!                                   (string-to-list 
table-cell-horizontal-chars))))
                  (and (table--goto-coordinate (cons (1+ (car coord)) (cdr 
coord)) 'no-extension)
!                      (looking-at (regexp-opt-charset
!                                   (string-to-list 
table-cell-horizontal-chars))))))
            (progn
              (delete-char 1)
              (insert table-cell-intersection-char))
***************
*** 4412,4420 ****
  (defun table--spacify-frame ()
    "Spacify table frame.
  Replace frame characters with spaces."
!   (let ((frame-char (list table-cell-intersection-char
!                         table-cell-horizontal-char
!                         table-cell-vertical-char)))
      (while
        (progn
          (cond
--- 4423,4431 ----
  (defun table--spacify-frame ()
    "Spacify table frame.
  Replace frame characters with spaces."
!   (let ((frame-char
!          (append (string-to-list table-cell-horizontal-chars)
!                  (list table-cell-intersection-char 
table-cell-vertical-char))))
      (while
        (progn
          (cond
***************
*** 4427,4437 ****
                     (table--spacify-frame))))
            (delete-char 1)
            (insert-before-markers ?\ ))
!          ((eq (char-after) table-cell-horizontal-char)
            (while (progn
                     (delete-char 1)
                     (insert-before-markers ?\ )
!                    (eq (char-after) table-cell-horizontal-char))))
           ((eq (char-after) table-cell-vertical-char)
            (while (let ((col (current-column)))
                     (delete-char 1)
--- 4438,4448 ----
                     (table--spacify-frame))))
            (delete-char 1)
            (insert-before-markers ?\ ))
!          ((table--cell-horizontal-char-p (char-after))
            (while (progn
                     (delete-char 1)
                     (insert-before-markers ?\ )
!                    (table--cell-horizontal-char-p (char-after)))))
           ((eq (char-after) table-cell-vertical-char)
            (while (let ((col (current-column)))
                     (delete-char 1)
***************
*** 4685,4692 ****
                (>= (if columnp (car coord) (cdr coord)) 0))
            (while (progn
                     (table--goto-coordinate coord 'no-extension 
'no-tab-expansion)
!                    (not (looking-at (format "[%c%c%c]"
!                                             table-cell-horizontal-char
                                              table-cell-vertical-char
                                              table-cell-intersection-char))))
              (if columnp (setcar coord (1- (car coord)))
--- 4696,4703 ----
                (>= (if columnp (car coord) (cdr coord)) 0))
            (while (progn
                     (table--goto-coordinate coord 'no-extension 
'no-tab-expansion)
!                    (not (looking-at (format "[%s%c%c]"
!                                             table-cell-horizontal-chars
                                              table-cell-vertical-char
                                              table-cell-intersection-char))))
              (if columnp (setcar coord (1- (car coord)))
***************
*** 5037,5043 ****
      (let ((vertical-str (regexp-quote (char-to-string 
table-cell-vertical-char)))
          (intersection-str (regexp-quote (char-to-string 
table-cell-intersection-char)))
          (v-border (format "[%c%c]" table-cell-vertical-char 
table-cell-intersection-char))
!         (h-border (format "[%c%c]" table-cell-horizontal-char 
table-cell-intersection-char))
          (limit (save-excursion (beginning-of-line) (point))))
        (catch 'end
        (while t
--- 5048,5054 ----
      (let ((vertical-str (regexp-quote (char-to-string 
table-cell-vertical-char)))
          (intersection-str (regexp-quote (char-to-string 
table-cell-intersection-char)))
          (v-border (format "[%c%c]" table-cell-vertical-char 
table-cell-intersection-char))
!         (h-border (format "[%s%c]" table-cell-horizontal-chars 
table-cell-intersection-char))
          (limit (save-excursion (beginning-of-line) (point))))
        (catch 'end
        (while t
***************
*** 5075,5081 ****
      (let ((vertical-str (regexp-quote (char-to-string 
table-cell-vertical-char)))
          (intersection-str (regexp-quote (char-to-string 
table-cell-intersection-char)))
          (v-border (format "[%c%c]" table-cell-vertical-char 
table-cell-intersection-char))
!         (h-border (format "[%c%c]" table-cell-horizontal-char 
table-cell-intersection-char))
          (limit (save-excursion (end-of-line) (point))))
        (catch 'end
        (while t
--- 5086,5092 ----
      (let ((vertical-str (regexp-quote (char-to-string 
table-cell-vertical-char)))
          (intersection-str (regexp-quote (char-to-string 
table-cell-intersection-char)))
          (v-border (format "[%c%c]" table-cell-vertical-char 
table-cell-intersection-char))
!         (h-border (format "[%s%c]" table-cell-horizontal-chars 
table-cell-intersection-char))
          (limit (save-excursion (end-of-line) (point))))
        (catch 'end
        (while t
***************
*** 5124,5131 ****
  When it fails to find either one of the cell corners it returns nil or
  signals error if the optional ABORT-ON-ERROR is non-nil."
    (let (lu rb
!       (border (format "^[%c%c%c]+$"
!                       table-cell-horizontal-char
                        table-cell-vertical-char
                        table-cell-intersection-char)))
      (if (and (condition-case nil
--- 5135,5142 ----
  When it fails to find either one of the cell corners it returns nil or
  signals error if the optional ABORT-ON-ERROR is non-nil."
    (let (lu rb
!       (border (format "^[%s%c%c]+$"
!                       table-cell-horizontal-chars
                        table-cell-vertical-char
                        table-cell-intersection-char)))
      (if (and (condition-case nil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]