From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nils Gustafsson Subject: Bug: Bad string comparison in org-all-archive-files (org 9.1.14) Date: Fri, 26 Oct 2018 17:50:57 +0200 Message-ID: <4ab6e236-0145-2cf6-446a-c969ca8288d1@bredband2.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG4Pn-0002ku-KV for emacs-orgmode@gnu.org; Fri, 26 Oct 2018 11:52:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG4Pi-00008F-7f for emacs-orgmode@gnu.org; Fri, 26 Oct 2018 11:52:47 -0400 Received: from cpanel.bredband2.com ([82.209.169.34]:37246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG4Pa-0007X6-LR for emacs-orgmode@gnu.org; Fri, 26 Oct 2018 11:52:36 -0400 Received: from c-36b3e255.021-49-756d651.bbcust.telenor.se ([85.226.179.54]:33714 helo=[192.168.1.8]) by cpanel.bredband2.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gG4Os-0000Ah-O1 for emacs-orgmode@gnu.org; Fri, 26 Oct 2018 17:51:50 +0200 Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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/)