all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Andreas Politz'" <politza@fh-trier.de>, <14029@debbugs.gnu.org>
Subject: bug#14029: 24.2.50; [PATCH] imenu problems with special elements
Date: Thu, 21 Mar 2013 22:12:34 -0700	[thread overview]
Message-ID: <5ABDF35DFCF64DEEAA37AFAE5048578D@us.oracle.com> (raw)
In-Reply-To: <87hak4gram.fsf@fh-trier.de>

Thanks for this report and fix.  Neither the original code nor your patch is
super clear to me, so I have some (non-rhetorical) questions below.  But if
someone else understands this better, feel free to ignore.

> | Special elements look like this:
> |           (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
> |      Selecting a special element performs:
> |           (funcall FUNCTION
> |                    INDEX-NAME INDEX-POSITION ARGUMENTS...)
> 
> 1. At least one function does not recognize these elements, resulting
> in an error.

Can you be more specific?  Which function?  What error?  Recipe to reproduce?
(Maybe you are referring to the last change in your patch, for `imenu'?)

> 2. The advertised calling convention is different from the 
> actual one in `imenu'.

How so?  What difference do you see, where?

> 3. The `imenu--subalist-p' predicate is unsafe and incomplete.

How so?

>   (defun imenu--subalist-p (item)
> !   (and (consp (cdr item)) (listp (cadr item))

   (defun imenu--subalist-p (item)
> !   (and (consp item)
> !        (consp (cdr item))
> !        (listp (cadr item))

(consp (cdr item)) is equivalent to
(and (consp item) (consp (cdr item))), assuming ITEM has the proper form (so
that cdr does not raise an error).  (consp (cdr-safe item)) should do the same
thing.

> !        (not (eq (car (cadr item)) 'lambda))))

> !        (not (functionp (cadr item)))))

Is it possible for (cadr item) to be a list and also be `functionp' and yet not
have its car be `lambda'?  Dunno.  I was under the impression that it was
impossible, but I could be wrong.  If it is possible, is it better to test
`functionp' here?  Dunno.

> ! 	     (if (setq res (imenu--in-alist str tail))

> ! 	     (if (and (imenu--subalist-p elt)
> !                 (setq res (imenu--in-alist str tail)))

Why is (imenu--subalist-p elt) needed here?  What error case does it prevent?  

Can't the code assume a properly constructed menu here, so that if TAIL is a
list then it is a bottom-level element, and so it is proper to just set ALIST to
nil?

> ! 	   (rest (if is-special-item (cddr index-item))))

> ! 	   (rest (if is-special-item (cdddr index-item))))

This change looks good, but `cdddr' is in cl.el, so perhaps it is better to use
(nthcdr 3 index-item).

I'm only a little bit surprised that this one hasn't already been reported and
fixed - there have been other bugs (e.g. #12717) related to special items.  I
use special items myself, but so far I have not used non-nil ARGS, so I have not
encountered this one (your last change).






  reply	other threads:[~2013-03-22  5:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22  1:24 bug#14029: 24.2.50; [PATCH] imenu problems with special elements Andreas Politz
2013-03-22  5:12 ` Drew Adams [this message]
     [not found]   ` <87ip4iwfoe.fsf@fh-trier.de>
2013-03-23 15:54     ` Andreas Politz
2013-03-23 16:15       ` Drew Adams
2013-11-24 23:53       ` Dmitry Gutov
2013-11-25  1:32         ` Andreas Politz
2013-11-29  3:43           ` Dmitry Gutov
2013-11-29 13:36             ` Andreas Politz
2013-11-29 14:35               ` Dmitry Gutov
2013-11-29 15:34               ` Drew Adams
2013-11-25  1:32         ` Andreas Politz
2013-11-25  1:40           ` Andreas Politz

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=5ABDF35DFCF64DEEAA37AFAE5048578D@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=14029@debbugs.gnu.org \
    --cc=politza@fh-trier.de \
    /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.