unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
Cc: jpw@gnu.org, klm@zope.com, emacs-devel@gnu.org,
	monnier@iro.umontreal.ca, storm@cua.dk,
	alexander.pohoyda@gmx.net
Subject: Re: how-many/count-matches for non-interactive use
Date: Sat, 23 Oct 2004 14:49:04 -0400	[thread overview]
Message-ID: <E1CLQwq-0003w2-Ag@fencepost.gnu.org> (raw)
In-Reply-To: <200410222222.i9MMMD515903@raven.dms.auburn.edu> (message from Luc Teirlinck on Fri, 22 Oct 2004 17:22:13 -0500 (CDT))

The code in allout.el uses interactive-p in a rather confused way.

The first use of interactive-p in allout is clearly a bug.
That command would fail in a macro.  The right way to right
that code is to read the argument inside the interactive spec.

Another use does call-interactively only if (interactive-p) is true.
That also is clearly wrong.

Many calls to interactive-p appear in functions that are not commands.
The only way interactive-p can return non-nil is when these functions
are called from commands run from macros.  It doesn't seem right for
allout commands to move the cursor differently when they are run from
macros.  So I am pretty sure these are bugs.

I think this is the right way to fix these bugs, but I don't use
allout.el.  Could someone who uses it please check this?


*** allout.el	04 Sep 2004 13:19:28 -0400	1.50
--- allout.el	23 Oct 2004 13:42:44 -0400	
***************
*** 954,973 ****
  \(require 'allout)
  \(allout-init t)"
  
!   (interactive)
!   (if (interactive-p)
!       (progn
! 	(setq mode
! 	      (completing-read
! 	       (concat "Select outline auto setup mode "
! 		       "(empty for report, ? for options) ")
! 	       '(("nil")("full")("activate")("deactivate")
! 		 ("ask") ("report") (""))
! 	       nil
! 	       t))
! 	(if (string= mode "")
! 	    (setq mode 'report)
! 	  (setq mode (intern-soft mode)))))
    (let
        ;; convenience aliases, for consistent ref to respective vars:
        ((hook 'allout-find-file-hook)
--- 954,969 ----
  \(require 'allout)
  \(allout-init t)"
  
!   (interactive
!    (let ((m (completing-read
! 	     (concat "Select outline auto setup mode "
! 		     "(empty for report, ? for options) ")
! 	     '(("nil")("full")("activate")("deactivate")
! 	       ("ask") ("report") (""))
! 	     nil
! 	     t)))
!      (if (string= m "") 'report
!        (intern-soft m))))
    (let
        ;; convenience aliases, for consistent ref to respective vars:
        ((hook 'allout-find-file-hook)
***************
*** 1904,1917 ****
                     depth)
            (goto-char last-good)
            nil))
!     (if (interactive-p) (allout-end-of-prefix))))
  ;;;_   > allout-ascend ()
  (defun allout-ascend ()
    "Ascend one level, returning t if successful, nil if not."
    (prog1
        (if (allout-beginning-of-level)
  	  (allout-previous-heading))
!     (if (interactive-p) (allout-end-of-prefix))))
  ;;;_   > allout-descend-to-depth (depth)
  (defun allout-descend-to-depth (depth)
    "Descend to depth DEPTH within current topic.
--- 1900,1913 ----
                     depth)
            (goto-char last-good)
            nil))
!     (allout-end-of-prefix)))
  ;;;_   > allout-ascend ()
  (defun allout-ascend ()
    "Ascend one level, returning t if successful, nil if not."
    (prog1
        (if (allout-beginning-of-level)
  	  (allout-previous-heading))
!     (allout-end-of-prefix)))
  ;;;_   > allout-descend-to-depth (depth)
  (defun allout-descend-to-depth (depth)
    "Descend to depth DEPTH within current topic.
***************
*** 1931,1943 ****
        nil))
    )
  ;;;_   > allout-up-current-level (arg &optional dont-complain)
! (defun allout-up-current-level (arg &optional dont-complain)
    "Move out ARG levels from current visible topic.
  
  Positions on heading line of containing topic.  Error if unable to
  ascend that far, or nil if unable to ascend but optional arg
  DONT-COMPLAIN is non-nil."
!   (interactive "p")
    (allout-back-to-current-heading)
    (let ((present-level (allout-recent-depth))
  	(last-good (point))
--- 1927,1939 ----
        nil))
    )
  ;;;_   > allout-up-current-level (arg &optional dont-complain)
! (defun allout-up-current-level (arg &optional dont-complain interactive)
    "Move out ARG levels from current visible topic.
  
  Positions on heading line of containing topic.  Error if unable to
  ascend that far, or nil if unable to ascend but optional arg
  DONT-COMPLAIN is non-nil."
!   (interactive "p\ni\np")
    (allout-back-to-current-heading)
    (let ((present-level (allout-recent-depth))
  	(last-good (point))
***************
*** 1958,1969 ****
      (if (or failed
  	    (> arg 0))
  	(progn (goto-char last-good)
! 	       (if (interactive-p) (allout-end-of-prefix))
  	       (if (not dont-complain)
  		   (error "Can't ascend past outermost level")
! 		 (if (interactive-p) (allout-end-of-prefix))
  		 nil))
!       (if (interactive-p) (allout-end-of-prefix))
        allout-recent-prefix-beginning)))
  
  ;;;_  - Linear
--- 1954,1965 ----
      (if (or failed
  	    (> arg 0))
  	(progn (goto-char last-good)
! 	       (if interactive (allout-end-of-prefix))
  	       (if (not dont-complain)
  		   (error "Can't ascend past outermost level")
! 		 (if interactive (allout-end-of-prefix))
  		 nil))
!       (if interactive (allout-end-of-prefix))
        allout-recent-prefix-beginning)))
  
  ;;;_  - Linear
***************
*** 2029,2035 ****
    (let ((depth (allout-depth)))
      (while (allout-previous-sibling depth nil))
      (prog1 (allout-recent-depth)
!       (if (interactive-p) (allout-end-of-prefix)))))
  ;;;_   > allout-next-visible-heading (arg)
  (defun allout-next-visible-heading (arg)
    "Move to the next ARG'th visible heading line, backward if arg is negative.
--- 2025,2031 ----
    (let ((depth (allout-depth)))
      (while (allout-previous-sibling depth nil))
      (prog1 (allout-recent-depth)
!       (allout-end-of-prefix))))
  ;;;_   > allout-next-visible-heading (arg)
  (defun allout-next-visible-heading (arg)
    "Move to the next ARG'th visible heading line, backward if arg is negative.
***************
*** 2067,2079 ****
    (interactive "p")
    (allout-next-visible-heading (- arg)))
  ;;;_   > allout-forward-current-level (arg)
! (defun allout-forward-current-level (arg)
    "Position point at the next heading of the same level.
  
  Takes optional repeat-count, goes backward if count is negative.
  
  Returns resulting position, else nil if none found."
!   (interactive "p")
    (let ((start-depth (allout-current-depth))
  	(start-point (point))
  	(start-arg arg)
--- 2063,2075 ----
    (interactive "p")
    (allout-next-visible-heading (- arg)))
  ;;;_   > allout-forward-current-level (arg)
! (defun allout-forward-current-level (arg &optional interactive)
    "Position point at the next heading of the same level.
  
  Takes optional repeat-count, goes backward if count is negative.
  
  Returns resulting position, else nil if none found."
!   (interactive "p\np")
    (let ((start-depth (allout-current-depth))
  	(start-point (point))
  	(start-arg arg)
***************
*** 2101,2107 ****
  		  (= (allout-recent-depth) start-depth)))
  	allout-recent-prefix-beginning
        (goto-char last-good)
!       (if (not (interactive-p))
  	  nil
  	(allout-end-of-prefix)
  	(error "Hit %s level %d topic, traversed %d of %d requested"
--- 2097,2103 ----
  		  (= (allout-recent-depth) start-depth)))
  	allout-recent-prefix-beginning
        (goto-char last-good)
!       (if (not interactive)
  	  nil
  	(allout-end-of-prefix)
  	(error "Hit %s level %d topic, traversed %d of %d requested"
***************
*** 2110,2119 ****
  	       (- (abs start-arg) arg)
  	       (abs start-arg))))))
  ;;;_   > allout-backward-current-level (arg)
! (defun allout-backward-current-level (arg)
    "Inverse of `allout-forward-current-level'."
!   (interactive "p")
!   (if (interactive-p)
        (let ((current-prefix-arg (* -1 arg)))
  	(call-interactively 'allout-forward-current-level))
      (allout-forward-current-level (* -1 arg))))
--- 2106,2115 ----
  	       (- (abs start-arg) arg)
  	       (abs start-arg))))))
  ;;;_   > allout-backward-current-level (arg)
! (defun allout-backward-current-level (arg &optional interactive)
    "Inverse of `allout-forward-current-level'."
!   (interactive "p\np")
!   (if interactive
        (let ((current-prefix-arg (* -1 arg)))
  	(call-interactively 'allout-forward-current-level))
      (allout-forward-current-level (* -1 arg))))

  parent reply	other threads:[~2004-10-23 18:49 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-24  6:09 [rmail-mbox-branch]: expunge Alfred M. Szmidt
2004-09-24  7:16 ` Kim F. Storm
2004-09-24  8:21   ` Alfred M. Szmidt
2004-09-24  9:23     ` Kim F. Storm
2004-09-24 12:03       ` Paul Michael Reilly
2004-09-25  7:08       ` Richard Stallman
2004-10-03 10:40         ` Alexander Pohoyda
2004-10-04 15:18           ` Richard Stallman
2004-10-06 21:38             ` [rmail-mbox-branch]: mail-utils Alexander Pohoyda
2004-10-06 21:47               ` Miles Bader
2004-10-08 23:34                 ` Alexander Pohoyda
2004-10-08 23:47                   ` Miles Bader
2004-10-09 16:04                     ` Alexander Pohoyda
2004-10-09 17:12                       ` Stefan
2004-10-09 18:15                         ` Alexander Pohoyda
2004-10-09 18:20                           ` Miles Bader
2004-10-09 21:02                             ` Alexander Pohoyda
2004-10-09 21:10                               ` Miles Bader
2004-10-09 21:19                                 ` Miles Bader
2004-10-10 15:15                                   ` Richard Stallman
2004-10-10 22:58                                     ` Miles Bader
2004-10-11 16:45                                       ` Richard Stallman
2004-10-12  2:09                                         ` Miles Bader
2004-10-12 14:42                                         ` Juri Linkov
2004-10-12 15:03                                           ` Miles Bader
2004-10-12 16:05                                             ` Syncing Gnus with Emacs and back (was: [rmail-mbox-branch]: mail-utils) Reiner Steib
2004-10-13  1:26                                               ` Syncing Gnus with Emacs and back Miles Bader
2004-10-13 20:21                                                 ` Reiner Steib
2004-10-13 22:51                                                   ` Miles Bader
2004-10-14  7:47                                                     ` Miles Bader
2004-10-13 14:43                                           ` [rmail-mbox-branch]: mail-utils Richard Stallman
2004-10-09 19:02                           ` Stefan
2004-10-09 20:40                             ` Alexander Pohoyda
2004-10-11 10:36                       ` Simon Josefsson
2004-10-08 16:06               ` Richard Stallman
2004-10-08 23:17                 ` Alexander Pohoyda
2004-10-10 15:16                   ` Richard Stallman
2004-10-10 23:50                     ` Alexander Pohoyda
2004-10-11 16:45                       ` Richard Stallman
2004-10-11 19:01                         ` Alexander Pohoyda
2004-10-12  8:57                           ` Richard Stallman
2004-10-12 16:12                             ` Alexander Pohoyda
2004-10-13 14:42                               ` Richard Stallman
2004-10-13 18:16 ` how-many/count-matches for non-interactive use Alexander Pohoyda
2004-10-15  0:26   ` Richard Stallman
2004-10-15  6:28     ` Alexander Pohoyda
2004-10-15 12:22       ` Richard Stallman
2004-10-15 15:30         ` Alexander Pohoyda
2004-10-16 13:52           ` Richard Stallman
2004-10-16 21:49             ` Alexander Pohoyda
2004-10-15 12:54     ` Stefan
2004-10-16 13:51       ` Richard Stallman
2004-10-16 18:41         ` Stefan Monnier
2004-10-16 22:00           ` Kim F. Storm
2004-10-17 15:19             ` Stefan Monnier
2004-10-17 20:53               ` Luc Teirlinck
2004-10-17 21:44                 ` Stefan Monnier
2004-10-18  8:39                 ` Kim F. Storm
2004-10-18 13:59                 ` Richard Stallman
2004-10-19  1:58                   ` Luc Teirlinck
2004-10-19  2:08                     ` Luc Teirlinck
2004-10-19 10:29                     ` Kim F. Storm
2004-10-19 17:17                       ` Alexander Pohoyda
2004-10-20 12:01                         ` Kim F. Storm
2004-10-19 16:46                     ` Richard Stallman
2004-10-19 22:08                       ` Kim F. Storm
2004-10-21  1:45                         ` Richard Stallman
2004-10-21  3:22                           ` Luc Teirlinck
2004-10-20  1:14                       ` Luc Teirlinck
2004-10-20  1:35                         ` David Kastrup
2004-10-20 13:28                         ` Robert J. Chassell
2004-10-20  1:27                       ` Luc Teirlinck
2004-10-21  1:45                         ` Richard Stallman
2004-10-21  3:08                           ` Luc Teirlinck
2004-10-22 10:47                             ` Richard Stallman
2004-10-22 12:54                               ` Convert keyboard macros to Lisp (was: how-many/count-matches for non-interactive use) Juri Linkov
2004-10-23 13:54                                 ` Richard Stallman
2004-10-22 17:35                               ` how-many/count-matches for non-interactive use Luc Teirlinck
2004-10-22 22:22                               ` Luc Teirlinck
2004-10-23  1:53                                 ` Luc Teirlinck
2004-10-23 11:32                                 ` John Paul Wallington
2004-10-23 18:49                                 ` Richard Stallman
2004-10-23 20:36                                   ` Luc Teirlinck
2004-10-24 17:09                                     ` Richard Stallman
2004-10-26  3:09                                       ` Luc Teirlinck
2004-10-26  8:19                                         ` Kim F. Storm
2004-11-02  8:53                                         ` Richard Stallman
2004-10-24  2:31                                   ` Luc Teirlinck
2004-10-24 17:09                                     ` Richard Stallman
2004-10-25  1:53                                       ` Luc Teirlinck
2004-10-26  9:05                                         ` Richard Stallman
2004-10-25  2:53                                       ` Luc Teirlinck
2004-10-26  9:04                                         ` Richard Stallman
2004-10-25  3:08                                       ` Luc Teirlinck
2004-10-24 17:09                                     ` Richard Stallman
2004-10-23 18:49                                 ` Richard Stallman [this message]
2004-10-25 14:04                                   ` Ken Manheimer
2004-10-27 10:49                                     ` Richard Stallman
2004-10-28  4:39                                     ` Ken Manheimer
2004-11-02 15:48                                       ` Ken Manheimer
2004-11-07  3:37                                         ` Richard Stallman
2004-10-23 18:49                                 ` Richard Stallman
2004-10-23 19:53                                   ` John Paul Wallington
2004-10-23 18:49                                 ` Richard Stallman
2004-10-21 22:13                           ` Luc Teirlinck
2004-10-23  4:48                             ` Richard Stallman
2004-10-23 16:03                               ` Luc Teirlinck
2004-10-18  8:32               ` Kim F. Storm
2004-10-17 16:07           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1CLQwq-0003w2-Ag@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=alexander.pohoyda@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=jpw@gnu.org \
    --cc=klm@zope.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=storm@cua.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).