all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* interactive-p fix for table.el
@ 2004-11-15 18:43 Tak Ota
  2004-11-17  5:04 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Tak Ota @ 2004-11-15 18:43 UTC (permalink / raw)


If the following patch looks OK someone please check it in.  Thanks in
advance.

-Tak


2004-11-15  Takaaki Ota  <Takaaki.Ota@am.sony.com>

	* textmodes/table.el (table-recognize-cell): Use a newly added
	optional argument PROBE-CURRENT-CELL instead of calling
	interactive-p.
	(table-query-dimension): Use a newly added optional argument
	VERBOSE instead of calling interactive-p.
	(table-generate-source): Use called-interactively-p instead of
	interactive-p.
	(table-insert-sequence): Ditto.
	(table--warn-incompatibility): Ditto.


*** pure/emacs-21.3.50/lisp/textmodes/table.el	Thu Nov  4 07:00:34 2004
--- emacs-21.3.50/lisp/textmodes/table.el	Thu Nov 11 16:41:13 2004
***************
*** 5,11 ****
  ;; Keywords: wp, convenience
  ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
  ;; Created: Sat Jul 08 2000 13:28:45 (PST)
! ;; Revised: Tue Jun 01 2004 11:36:39 (PDT)
  
  ;; This file is part of GNU Emacs.
  
--- 5,11 ----
  ;; Keywords: wp, convenience
  ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
  ;; Created: Sat Jul 08 2000 13:28:45 (PST)
! ;; Revised: Thu Nov 11 2004 16:41:13 (PST)
  
  ;; This file is part of GNU Emacs.
  
***************
*** 2043,2059 ****
    (table-recognize-table -1))
  
  ;;;###autoload
! (defun table-recognize-cell (&optional force no-copy arg)
    "Recognize a table cell that contains current point.
  Probe the cell dimension and prepare the cell information.  The
! optional two arguments FORCE and NO-COPY are for internal use only and
! must not be specified.  When the optional numeric prefix argument ARG
! is negative the cell becomes inactive, meaning that the cell becomes
! plain text and loses all the table specific features."
!   (interactive "i\ni\np")
    (table--make-cell-map)
    (if (or force (not (memq (table--get-last-command) table-command-list)))
!       (let* ((cell (table--probe-cell (interactive-p)))
  	     (cache-buffer (get-buffer-create table-cache-buffer-name))
  	     (modified-flag (buffer-modified-p))
  	     (inhibit-read-only t))
--- 2043,2062 ----
    (table-recognize-table -1))
  
  ;;;###autoload
! (defun table-recognize-cell (&optional force no-copy arg probe-current-cell)
    "Recognize a table cell that contains current point.
  Probe the cell dimension and prepare the cell information.  The
! optional two arguments FORCE and NO-COPY are for internal use
! only and must not be specified.  When the optional numeric prefix
! argument ARG is negative the cell becomes inactive, meaning that
! the cell becomes plain text and loses all the table specific
! features.  If PROBE-CURRENT-CELL is non-nil (which is always,
! when called interactively), the cell at the current point is
! probed and flush the delayed tasks if necessary."
!   (interactive "i\ni\np\np")
    (table--make-cell-map)
    (if (or force (not (memq (table--get-last-command) table-command-list)))
!       (let* ((cell (table--probe-cell probe-current-cell))
  	     (cache-buffer (get-buffer-create table-cache-buffer-name))
  	     (modified-flag (buffer-modified-p))
  	     (inhibit-read-only t))
***************
*** 2947,2964 ****
    (table--update-cell-face))
  
  ;;;###autoload
! (defun table-query-dimension (&optional where)
    "Return the dimension of the current cell and the current table.
  The result is a list (cw ch tw th c r cells) where cw is the cell
! width, ch is the cell height, tw is the table width, th is the table
! height, c is the number of columns, r is the number of rows and cells
! is the total number of cells.  The cell dimension excludes the cell
! frame while the table dimension includes the table frame.  The columns
! and the rows are counted by the number of cell boundaries.  Therefore
! the number tends to be larger than it appears for the tables with
! non-uniform cell structure (heavily spanned and split).  When optional
! WHERE is provided the cell and table at that location is reported."
!   (interactive)
    (save-excursion
      (if where (goto-char where))
      (let ((starting-cell (table--probe-cell))
--- 2950,2971 ----
    (table--update-cell-face))
  
  ;;;###autoload
! (defun table-query-dimension (&optional where verbose)
    "Return the dimension of the current cell and the current table.
  The result is a list (cw ch tw th c r cells) where cw is the cell
! width, ch is the cell height, tw is the table width, th is the
! table height, c is the number of columns, r is the number of rows
! and cells is the total number of cells.  The cell dimension
! excludes the cell frame while the table dimension includes the
! table frame.  The columns and the rows are counted by the number
! of cell boundaries.  Therefore the number tends to be larger than
! it appears for the tables with non-uniform cell
! structure (heavily spanned and split).  When optional WHERE is
! provided the cell and table at that location is reported.  If
! VERBOSE is non-nil (which is always, when called interactively),
! prints the some messages including human friendly result in the
! minibuffer."
!   (interactive "P\np")
    (save-excursion
      (if where (goto-char where))
      (let ((starting-cell (table--probe-cell))
***************
*** 2968,2975 ****
  	(setq table-rb (cdr starting-cell))
  	(setq col-list (cons (car (table--get-coordinate (car starting-cell))) nil))
  	(setq row-list (cons (cdr (table--get-coordinate (car starting-cell))) nil))
! 	(and (interactive-p)
! 	     (message "Computing cell dimension..."))
  	(while
  	    (progn
  	      (table-forward-cell 1 t)
--- 2975,2982 ----
  	(setq table-rb (cdr starting-cell))
  	(setq col-list (cons (car (table--get-coordinate (car starting-cell))) nil))
  	(setq row-list (cons (cdr (table--get-coordinate (car starting-cell))) nil))
! 	(if verbose
! 	    (message "Computing cell dimension..."))
  	(while
  	    (progn
  	      (table-forward-cell 1 t)
***************
*** 2995,3002 ****
  	       (th (+ 3 (- (cdr table-rb-coordinate) (cdr table-lu-coordinate))))
  	       (c (length col-list))
  	       (r (length row-list)))
! 	  (and (interactive-p)
! 	       (message "Cell: (%dw, %dh), Table: (%dw, %dh), Dim: (%dc, %dr), Total Cells: %d" cw ch tw th c r cells))
  	  (list cw ch tw th c r cells))))))
  
  ;;;###autoload
--- 3002,3009 ----
  	       (th (+ 3 (- (cdr table-rb-coordinate) (cdr table-lu-coordinate))))
  	       (c (length col-list))
  	       (r (length row-list)))
! 	  (if verbose
! 	      (message "Cell: (%dw, %dh), Table: (%dw, %dh), Dim: (%dc, %dr), Total Cells: %d" cw ch tw th c r cells))
  	  (list cw ch tw th c r cells))))))
  
  ;;;###autoload
***************
*** 3040,3046 ****
        (read-buffer "Destination buffer: " (concat table-dest-buffer-name "." language))
        (table--read-from-minibuffer '("Table Caption" . table-source-caption-history)))))
    (let ((default-buffer-name (concat table-dest-buffer-name "." (symbol-name language))))
!     (unless (or (interactive-p) (table--probe-cell)) (error "Table not found here"))
      (unless (bufferp dest-buffer)
        (setq dest-buffer (get-buffer-create (or dest-buffer default-buffer-name))))
      (if (string= (buffer-name dest-buffer) default-buffer-name)
--- 3047,3053 ----
        (read-buffer "Destination buffer: " (concat table-dest-buffer-name "." language))
        (table--read-from-minibuffer '("Table Caption" . table-source-caption-history)))))
    (let ((default-buffer-name (concat table-dest-buffer-name "." (symbol-name language))))
!     (unless (or (called-interactively-p) (table--probe-cell)) (error "Table not found here"))
      (unless (bufferp dest-buffer)
        (setq dest-buffer (get-buffer-create (or dest-buffer default-buffer-name))))
      (if (string= (buffer-name dest-buffer) default-buffer-name)
***************
*** 3062,3068 ****
  	(let ((wheel [?- ?\\ ?| ?/]))
  	  (while
  	      (progn
! 		(if (interactive-p)
  		    (progn
  		      (message "Analyzing table...%c" (aref wheel i))
  		      (if (eq (setq i (1+ i)) (length wheel))
--- 3069,3075 ----
  	(let ((wheel [?- ?\\ ?| ?/]))
  	  (while
  	      (progn
! 		(if (called-interactively-p)
  		    (progn
  		      (message "Analyzing table...%c" (aref wheel i))
  		      (if (eq (setq i (1+ i)) (length wheel))
***************
*** 3099,3105 ****
  	;; insert closing
  	(table--generate-source-epilogue dest-buffer language col-list row-list))
        ;; lastly do some convenience work
!       (if (interactive-p)
  	  (save-selected-window
  	    (pop-to-buffer dest-buffer t)
  	    (goto-char (point-min))
--- 3106,3112 ----
  	;; insert closing
  	(table--generate-source-epilogue dest-buffer language col-list row-list))
        ;; lastly do some convenience work
!       (if (called-interactively-p)
  	  (save-selected-window
  	    (pop-to-buffer dest-buffer t)
  	    (goto-char (point-min))
***************
*** 3448,3456 ****
  				(format "Justify (default %s): " default)
  				'(("left") ("center") ("right"))
  				nil t nil 'table-sequence-justify-history default)))))))
!   (unless (or (interactive-p) (table--probe-cell)) (error "Table not found here"))
    (string-match "\\([0-9]*\\)\\([]})>]*\\)\\'" str)
!   (if (interactive-p)
        (message "Sequencing..."))
    (let* ((prefix (substring str 0 (match-beginning 1)))
  	 (index (match-string 1 str))
--- 3455,3463 ----
  				(format "Justify (default %s): " default)
  				'(("left") ("center") ("right"))
  				nil t nil 'table-sequence-justify-history default)))))))
!   (unless (or (called-interactively-p) (table--probe-cell)) (error "Table not found here"))
    (string-match "\\([0-9]*\\)\\([]})>]*\\)\\'" str)
!   (if (called-interactively-p)
        (message "Sequencing..."))
    (let* ((prefix (substring str 0 (match-beginning 1)))
  	 (index (match-string 1 str))
***************
*** 3498,3504 ****
  	       (setq cells (1- cells))
  	       (and (> n 0) (> cells 0)))))
      (table-recognize-cell 'force)
!     (if (interactive-p)
  	(message "Sequencing...done"))
      ))
  
--- 3505,3511 ----
  	       (setq cells (1- cells))
  	       (and (> n 0) (> cells 0)))))
      (table-recognize-cell 'force)
!     (if (called-interactively-p)
  	(message "Sequencing...done"))
      ))
  
***************
*** 5346,5352 ****
  This feature is disabled when `table-disable-incompatibility-warning'
  is non-nil.  The warning is done only once per session for each item."
    (unless (and table-disable-incompatibility-warning
! 	       (not (interactive-p)))
      (cond ((and (featurep 'xemacs)
  		(not (get 'table-disable-incompatibility-warning 'xemacs)))
  	   (put 'table-disable-incompatibility-warning 'xemacs t)
--- 5353,5359 ----
  This feature is disabled when `table-disable-incompatibility-warning'
  is non-nil.  The warning is done only once per session for each item."
    (unless (and table-disable-incompatibility-warning
! 	       (not (called-interactively-p)))
      (cond ((and (featurep 'xemacs)
  		(not (get 'table-disable-incompatibility-warning 'xemacs)))
  	   (put 'table-disable-incompatibility-warning 'xemacs t)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: interactive-p fix for table.el
  2004-11-15 18:43 interactive-p fix for table.el Tak Ota
@ 2004-11-17  5:04 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2004-11-17  5:04 UTC (permalink / raw)
  Cc: emacs-devel

In cases where it only controls a message, as here,

		   (setq cells (1- cells))
		   (and (> n 0) (> cells 0)))))
	  (table-recognize-cell 'force)
    !     (if (interactive-p)
	    (message "Sequencing...done"))
	  ))

it is ok to use interactive-p.

In some cases, both the old code and the new code must be wrong.
For instance,

    ***************
    *** 5346,5352 ****
      This feature is disabled when `table-disable-incompatibility-warning'
      is non-nil.  The warning is done only once per session for each item."
	(unless (and table-disable-incompatibility-warning
    ! 	       (not (interactive-p)))
	  (cond ((and (featurep 'xemacs)
		    (not (get 'table-disable-incompatibility-warning 'xemacs)))
	       (put 'table-disable-incompatibility-warning 'xemacs t)
    --- 5353,5359 ----
      This feature is disabled when `table-disable-incompatibility-warning'
      is non-nil.  The warning is done only once per session for each item."
	(unless (and table-disable-incompatibility-warning
    ! 	       (not (called-interactively-p)))
	  (cond ((and (featurep 'xemacs)
		    (not (get 'table-disable-incompatibility-warning 'xemacs)))
	       (put 'table-disable-incompatibility-warning 'xemacs t)

Since this function is not interactive, both interactive-p and
called-interactively-p will always return nil in this function.
Whatever you want to do, you need to do it some other way.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-17  5:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-15 18:43 interactive-p fix for table.el Tak Ota
2004-11-17  5:04 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.