bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#18183: 24.3; table-fixed-width-mode fails with kill/yank


From: Boruch Baum
Subject: bug#18183: 24.3; table-fixed-width-mode fails with kill/yank
Date: Mon, 7 Dec 2020 13:21:56 -0500
User-agent: NeoMutt/20180716

I think I have a fix, centered around adding two lines to function
table--update-cell. In the snippet below, the new lines are marked with
an arrow ; <--------


(defun table--update-cell (&optional now)
  "Update the table cell contents.
When the optional parameter NOW is nil it only sets up the update
timer.  If it is non-nil the function copies the contents of the cell
cache buffer into the designated cell in the table buffer."
  (if (null table-update-timer) nil
    (table--cancel-timer table-update-timer)
    (setq table-update-timer nil))
  (if (or (not now)
          (and (boundp 'quail-converting)
               quail-converting) ;; defer operation while current quail work is 
not finished.
          (and (boundp 'quail-translating)
               quail-translating))
      (setq table-update-timer
            (table--set-timer table-time-before-update
                              (function table--update-cell)
                              'now))
    (save-current-buffer
      (set-buffer table-cell-buffer)
      (let ((cache-buffer (get-buffer-create table-cache-buffer-name))
            (org-coord (table--get-coordinate))
            (fixed table-fixed-width-mode) ; <--------
            (in-cell (equal (table--cell-to-coord (table--probe-cell))
                            (cons table-cell-info-lu-coordinate 
table-cell-info-rb-coordinate)))
            rectangle)
        (set-buffer cache-buffer)
        (setq-local table-fixed-width-mode fixed) ; <---------
        (setq rectangle
              (extract-rectangle
               1
               (table--goto-coordinate (cons table-cell-info-width (1- 
table-cell-info-height)))))
        (set-buffer table-cell-buffer)
        (delete-rectangle (table--goto-coordinate table-cell-info-lu-coordinate)
                          (table--goto-coordinate 
table-cell-info-rb-coordinate))
        (table--goto-coordinate table-cell-info-lu-coordinate)
        (table--insert-rectangle rectangle)
        (let* ((cell (table--probe-cell))) ; must probe again in case of wide 
characters
          (table--put-cell-property cell)
          (table--put-cell-justify-property cell table-cell-info-justify)
          (table--put-cell-valign-property cell table-cell-info-valign))
        (table--goto-coordinate
         (if in-cell
             (table--transcoord-cache-to-table 
table-cell-cache-point-coordinate)
           org-coord))))
    ;; simulate undo behavior under overwrite-mode
    (if (and overwrite-mode (not (eq buffer-undo-list t)))
        (setq buffer-undo-list (cons nil buffer-undo-list)))))


--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





reply via email to

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