emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nils Gustafsson <nils.gustafsson@bredband2.com>
To: emacs-orgmode@gnu.org
Subject: Bug: Bad string comparison in org-all-archive-files (org 9.1.14)
Date: Fri, 26 Oct 2018 17:50:57 +0200	[thread overview]
Message-ID: <4ab6e236-0145-2cf6-446a-c969ca8288d1@bredband2.com> (raw)

Hi

I've encountered and, I think, diagnosed the cause of a bug in
org-archive.el


Background:

I stubled upon this while trying to work out why my clocktables
weren't behaving as expected. In one of my org files I have several
large trees set up to use different archive files via :ARCHIVE:
properties, and the clocktable I added with :scope file-with-archives
seemed to be ignoring those archives.

Except it worked fine when I used a default archive for the whole
file, or added a custom one using #+ARCHIVE: instead. After some
experimenting and digging around in the source code I've found that
the actual problem is a bad string comparison in a function called
org-all-archive-files in org-archive.el.


The issue:

The real problem turns out to be that org-all-archive-files does not
do what it says on the can. It should list all archive files for the
current buffer, but will fail to pick up archive files listed in
:ARCHIVE: properties.

To reproduce, make a new org file called temp.org (or your choice of
name) containing something like:

* Test-heading
   :PROPERTIES:
   :ARCHIVE: test_archive::
   :END:


Then create an empty file called test_archive in the same directory,
and try calling (message "archives: %s" (org-all-archive-files)) in
that buffer.


Expected output: "archives: (/some/path/test_archive)"

Actual output: "archives: nil"


The cause:

Specifically the error is in this part of org-all-archive-files
starting on line 170 of org-archive.el (original indentation not
preserved):


(when (save-match-data
   (if (eq (match-string 1) ":") (org-at-property-p)
     (eq (org-element-type (org-element-at-point)) 'keyword))) ...


That (eq (match-string 1) ":") always fails. Replacing eq with string=
in that expression seems to restore the expected behaviour:
org-all-archive-files no longer ignores archive files listed in
:ARCHIVE: properties. And indeed, it resolves the clocktable issue I
was having as well.


Nils Gustafsson


My emacs and org version (as printed by org-submit-bug-report):

Emacs  : GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
  of 2017-09-15, modified by Debian
Package: Org mode version 9.1.14 (9.1.14-7-g01c419-elpa @ 
/home/nils/.emacs.d/.cask/25.1/elpa/org-20181022/)

             reply	other threads:[~2018-10-26 15:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 15:50 Nils Gustafsson [this message]
2018-11-01 21:47 ` Bug: Bad string comparison in org-all-archive-files (org 9.1.14) Nicolas Goaziou

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.orgmode.org/

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

  git send-email \
    --in-reply-to=4ab6e236-0145-2cf6-446a-c969ca8288d1@bredband2.com \
    --to=nils.gustafsson@bredband2.com \
    --cc=emacs-orgmode@gnu.org \
    /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/org-mode.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).