all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ken Manheimer" <ken.manheimer@gmail.com>
To: "martin rudalics" <rudalics@gmx.at>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Bug in allout-hide-current-leaves
Date: Mon, 21 Jan 2008 13:49:04 -0500	[thread overview]
Message-ID: <2cd46e7f0801211049q442b2b27lcc6cf7437aad48c3@mail.gmail.com> (raw)
In-Reply-To: <47923267.2090500@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 1937 bytes --]

martin, thanks for the details report.  i'm attaching a patch and
ChangeLog - they includes fixes for some other people's changes, as
well.  details below, inline.

On Jan 19, 2008 12:24 PM, martin rudalics <rudalics@gmx.at> wrote:
> To reproduce with Emacs -Q: Open src/keyboard.c, do M-x allout-mode, and
> M-x allout-hide-current-leaves.  Gets me:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   -(nil nil 2)
>   (max 1 (- allout-recent-prefix-end allout-recent-prefix-beginning allout-header-subtraction))
>   (setq allout-recent-prefix-end (or (match-end 1) (match-end 2)) allout-recent-prefix-beginning (or (match-beginning 1) (match-beginning 2)) allout-recent-depth (max 1 (- allout-recent-prefix-end allout-recent-prefix-beginning
> allout-header-subtraction)))
>   allout-prefix-data()
> [...]
>   execute-extended-command(nil)
>   call-interactively(execute-extended-command)
>
> Note that `allout-regexp' is
>
> "\\(/\\*_[      ]*[\\.,\\*\\+--=>()\\[{}&!\\?#%\"X@\\$~_\\\\:;\\^/\\*_]\\)\\|\\(/\\*_\\|/\\*_\\)+ ?[^/*_]\\|\f"
>
> hence it cannot possibly match _two_ parenthetical subexpressions.

not quite.  that's more clear if you look at the expression as a
concatenation of a few:

(concat  "\\(/\\*_[
]*[\\.,\\*\\+--=>()\\[{}&!\\?#%\"X@\\$~_\\\\:;\\^/\\*_]\\)"
             "\\|\\(/\\*_\\|/\\*_\\)+ ?[^/*_]"
             "\\|\f")

the actual problem here is that the match on the third alternative,
the ^L formfeed, is not itself a top-level alternative in the
expression.  i've rectified that, and some related things.

along the way i discovered that some error handling code was mangled,
both in a misguided blanket alteration of expressions that look like
error functions (for which `error' condition handlers in
condition-case statements can be mistaken), and in the subsequent
attempt to repair it, which left inert nonsensical code in its wake.


-- 
ken
http://myriadicity.net

[-- Attachment #2: allout-patch.txt --]
[-- Type: text/plain, Size: 6168 bytes --]

Index: allout.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/allout.el,v
retrieving revision 1.103
diff -u -u -r1.103 allout.el
--- allout.el	8 Jan 2008 20:44:36 -0000	1.103
+++ allout.el	21 Jan 2008 18:06:17 -0000
@@ -155,11 +155,11 @@
         ("*" allout-rebullet-current-heading)
         ("#" allout-number-siblings)
         ("\C-k" allout-kill-line t)
-        ("\M-k" allout-copy-line-as-kill t)
+        ([?\M-k] allout-copy-line-as-kill t)
         ("\C-y" allout-yank t)
-        ("\M-y" allout-yank-pop t)
+        ([?\M-y] allout-yank-pop t)
         ("\C-k" allout-kill-topic)
-        ("\M-k" allout-copy-topic-as-kill)
+        ([?\M-k] allout-copy-topic-as-kill)
                                         ; Miscellaneous commands:
 	;([?\C-\ ] allout-mark-topic)
         ("@" allout-resolve-xref)
@@ -886,7 +886,7 @@
 (make-variable-buffer-local 'allout-depth-one-regexp)
 ;;;_   = allout-line-boundary-regexp
 (defvar allout-line-boundary-regexp ()
-  "`allout-regexp' with outline style beginning-of-line anchor.
+  "`allout-regexp' prepended with a newline for the search target.
 
 This is properly set by `set-allout-regexp'.")
 (make-variable-buffer-local 'allout-line-boundary-regexp)
@@ -1058,7 +1058,7 @@
   (setq allout-plain-bullets-string-len (length allout-plain-bullets-string))
   (setq allout-header-subtraction (1- (length allout-header-prefix)))
 
-  (let (new-part old-part)
+  (let (new-part old-part formfeed-part)
     (setq new-part (concat "\\("
                            (regexp-quote allout-header-prefix)
                            "[ \t]*"
@@ -1072,18 +1072,26 @@
                            "\\)"
                            "+"
                            " ?[^" allout-primary-bullet "]")
+          formfeed-part "\\(\^L\\)"
+
           allout-regexp (concat new-part
                                 "\\|"
                                 old-part
-                                "\\|\^l")
+                                "\\|"
+                                formfeed-part)
 
           allout-line-boundary-regexp (concat "\n" new-part
                                               "\\|"
-                                              "\n" old-part)
+                                              "\n" old-part
+                                              "\\|"
+                                              "\n" formfeed-part)
 
           allout-bob-regexp (concat "\\`" new-part
                                     "\\|"
-                                    "\\`" old-part))
+                                    "\\`" old-part
+                                    "\\|"
+                                    "\\`" formfeed-part
+                                    ))
 
     (setq allout-depth-specific-regexp
           (concat "\\(^\\|\\`\\)"
@@ -1501,13 +1509,12 @@
             (condition-case failure
                 (setq allout-after-save-decrypt
                       (allout-encrypt-decrypted except-mark))
-	      (message "allout-write-file-hook-handler suppressing error %s"
-		       failure)
-	      (sit-for 2)
-	      (error "allout-write-file-hook-handler suppressing error %s"
-		     failure))))
+              (error (message
+                      "allout-write-file-hook-handler suppressing error %s"
+                      failure)
+                     (sit-for 2)))))
       ))
-    nil)
+  nil)
 ;;;_   > allout-auto-save-hook-handler ()
 (defun allout-auto-save-hook-handler ()
   "Implement `allout-encrypt-unencrypted-on-saves' policy for auto save."
@@ -2146,7 +2153,7 @@
 ;;;                                                &optional prelen)
 (defun allout-overlay-insert-in-front-handler (ol after beg end
                                                   &optional prelen)
-  "Shift the overlay so stuff inserted in front of it is excluded."
+  "Shift the overlay so stuff inserted in front of it is not included."
   (if after
       ;; XXX Shouldn't moving the overlay should be unnecessary, if overlay
       ;;     front-advance on the overlay worked as it should?
@@ -2253,9 +2260,10 @@
   "Register allout-prefix state data.
 
 For reference by `allout-recent' funcs.  Returns BEGINNING."
-  (setq allout-recent-prefix-end (or (match-end 1) (match-end 2))
+  (setq allout-recent-prefix-end (or (match-end 1) (match-end 2) (match-end 3))
         allout-recent-prefix-beginning (or (match-beginning 1)
-                                           (match-beginning 2))
+                                           (match-beginning 2)
+                                           (match-beginning 3))
         allout-recent-depth (max 1 (- allout-recent-prefix-end
                                       allout-recent-prefix-beginning
                                       allout-header-subtraction)))
@@ -2384,6 +2392,8 @@
 (defun allout-depth ()
   "Return depth of topic most immediately containing point.
 
+Does not do doublecheck for aberrant topic header.
+
 Return zero if point is not within any topic.
 
 Like `allout-current-depth', but respects hidden as well as visible topics."
@@ -2572,10 +2582,14 @@
 
     (when (re-search-forward allout-line-boundary-regexp nil 0)
       (allout-prefix-data)
+      (goto-char allout-recent-prefix-beginning)
+      (while (not (bolp))
+        (forward-char -1))
       (and (allout-do-doublecheck)
            ;; this will set allout-recent-* on the first non-aberrant topic,
            ;; whether it's the current one or one that disqualifies it:
            (allout-aberrant-container-p))
+      ;; this may or may not be the same as above depending on doublecheck:
       (goto-char allout-recent-prefix-beginning))))
 ;;;_   > allout-this-or-next-heading
 (defun allout-this-or-next-heading ()
@@ -5462,7 +5476,7 @@
   (if (fboundp 'use-region-p)
       '(use-region-p)
     '(region-active-p)))
-;;;_   > allout-process-exposed (&optional func from to frombuf
+;;_   > allout-process-exposed (&optional func from to frombuf
 ;;;					    tobuf format)
 (defun allout-process-exposed (&optional func from to frombuf tobuf
 					  format start-num)

[-- Attachment #3: ChangeLog-entry.txt --]
[-- Type: text/plain, Size: 1355 bytes --]

2008-01-21  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el (allout-keybindings-list): In initial setting, express
	meta-prefixed allout keys as vectors instead of strings, since the
	string form is interpreted in some cases as composed key
	modifiers, eg, accented keys.

	(allout-line-boundary-regexp): Clarify description.

	(set-allout-regexp): Repair the expressions so that the formfeed
	part 1. is identified as one of the top-level groups, and 2. is
	included in all the forms, not just the -line-boundary-regexp one.

	(allout-prefix-data): Incorporate information from the various
	allout regexp's formfeed alternative group, when present.

	(allout-write-file-hook-handler): Remove mangling of the error
	handling.  It was broken in version 1.100, where an `error'
	condition-case handler was mistreated as if it was a call to the
	error function.  A repair attempt in version 1.101 situated the
	original body of the error handling code as bogus condition-case
	handlers.  I've returned to just about the working code that was
	originally there, removing an unnecessary - but benign - enclosing
	'progn'.  Automated or cursory code fixes often aren't.

	(allout-region-active-p): Fallback to value of mark-active if
	neither use-region-p nor region-active-p are present, for
	compatability with current and recent emacs major releases.

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2008-01-21 18:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-19 17:24 Bug in allout-hide-current-leaves martin rudalics
2008-01-21  9:08 ` Richard Stallman
2008-01-21 18:49 ` Ken Manheimer [this message]
2008-01-21 18:59   ` Ken Manheimer
2008-01-21 19:35     ` martin rudalics
2008-01-21 23:45       ` Ken Manheimer
2008-01-22 22:29         ` Richard Stallman
2008-01-26 16:49         ` Ken Manheimer

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

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

  git send-email \
    --in-reply-to=2cd46e7f0801211049q442b2b27lcc6cf7437aad48c3@mail.gmail.com \
    --to=ken.manheimer@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /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 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.