emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: David Maus <dmaus@ictsoc.de>
To: Bastien <bzg@altern.org>
Cc: emacs-orgmode@gnu.org, Paul Sexton <psexton@xnet.co.nz>
Subject: Re: Typo in 'org-without-partial-completion'
Date: Thu, 30 Jun 2011 21:28:08 +0200	[thread overview]
Message-ID: <871uybdsqf.wl%dmaus@ictsoc.de> (raw)
In-Reply-To: <87wrg3k7io.fsf@gnu.org>

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

At Thu, 30 Jun 2011 11:12:15 +0200,
Bastien wrote:
> Hi Paul,
> Paul Sexton <psexton@xnet.co.nz> writes:
> > I think there's an error in 'org-without-partial-completion' in org-macs.el.
> > The variable pc-mode gets bound to the value of partial-completion-mode - but 
> > this is a VARIABLE (t if that mode is enabled). Funcalling the value of 
> > the variable produces an error, unsurprisingly. This breaks insertion of 
> > properties with 'org-set-property'. 
> >
> > Fixing it involves quoting the the symbol as shown below:
> >
> >
> > (defmacro org-without-partial-completion (&rest body)
> >    `(let ((pc-mode (and (boundp 'partial-completion-mode)
> >                         'partial-completion-mode)))   ; <-- quote added
> >       (unwind-protect
> >           (progn
> >             (when pc-mode (funcall pc-mode -1))
> >             ,@body)
> >         (when pc-mode (funcall pc-mode 1)))))
> I've just reverted this modification, per Sebastian report.
> Can you be more precise about the problem it creates with
> org-set-property?
> Can you check if this version fixes the problems, if any?
> #+begin_src emacs-lisp
> (defmacro org-without-partial-completion (&rest body)
>   `(let ((pc-mode ,(and (boundp 'partial-completion-mode)
> 			'partial-completion-mode)))
>      (unwind-protect
> 	 (progn
> 	   (when pc-mode (funcall pc-mode -1))
> 	   ,@body)
>        (when pc-mode (funcall pc-mode 1)))))
> #+end_src emacs-lisp

No, I think this won't work. On compile time the byte compiler will
expand the macro and place the expansion in the byte compiled
lisp. Thus it will evaluate the ,(and ...) condition at compile time.


When a macro call appears in a Lisp program being compiled, the Lisp
compiler calls the macro definition just as the interpreter would, and
receives an expansion. But instead of evaluating this expansion, it
compiles the expansion as if it had appeared directly in the
program. As a result, the compiled code produces the value and side
effects intended for the macro, but executes at full compiled
speed. This would not work if the macro body computed the value and
side effects itself—they would be computed at compile time, which is
not useful.

What about this:

#+begin_src emacs-lisp
  (defmacro org-without-partial-completion (&rest body)
    `(let ((pc-mode-p (and (boundp 'partial-completion-mode)
                           (fboundp 'partial-completion-mode))))
       (when pc-mode-p
               (partial-completion-mode -1)
           (partial-completion-mode 1)))))

This will turn off partial-completion-mode if the symbol is non-nil
and callable.

For Sebastien's problem: Strange thing. Looks like the symbol
partial-completion-mode is non-nil but not callable. 

Maybe an Emacs 24 development version issue?

  -- David
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]

  reply	other threads:[~2011-06-30 19:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22 21:08 Typo in 'org-without-partial-completion' Paul Sexton
2011-06-28 16:48 ` Bastien
2011-06-30  9:12 ` Bastien
2011-06-30 19:28   ` David Maus [this message]
2011-07-02  7:34     ` David Maus
2011-07-02  9:26       ` Bastien
2011-07-02 13:50         ` David Maus
2011-07-02 14:40       ` Nick Dokos
2011-07-02 14:55         ` David Maus
2011-07-03 10:44           ` Bastien

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:

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=871uybdsqf.wl%dmaus@ictsoc.de \
    --to=dmaus@ictsoc.de \
    --cc=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=psexton@xnet.co.nz \


* 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


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).