From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: bugs in property searches? Date: Tue, 28 Jan 2014 21:00:22 -0500 Message-ID: <87wqhjv96x.fsf@andrew.cmu.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8KWg-0001xF-G1 for emacs-orgmode@gnu.org; Tue, 28 Jan 2014 21:05:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8KWZ-0001ws-2D for emacs-orgmode@gnu.org; Tue, 28 Jan 2014 21:05:14 -0500 Received: from plane.gmane.org ([80.91.229.3]:41230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8KWY-0001uf-PG for emacs-orgmode@gnu.org; Tue, 28 Jan 2014 21:05:07 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W8KWW-0006CF-5J for emacs-orgmode@gnu.org; Wed, 29 Jan 2014 03:05:04 +0100 Received: from vpn-128-237-145-151.library.vpn.cmu.edu ([128.237.145.151]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 03:05:04 +0100 Received: from jkitchin by vpn-128-237-145-151.library.vpn.cmu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 03:05:04 +0100 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Everyone, I am experimenting with using an org-file as a database of sorts. The idea is to have some heading like this that represent courses, with various classifications (tags) and properties. Then, I would generate reports on these headings. I have run across to behaviors that seem like bugs to me. 1. the point moves in org-map-entries, and I thought it would not since the documentation says the function is wrapped in save-excursion. This lead to the results going in the wrong place. 2. In using a PROPERTY search, headings that did not have the property got "mapped".Scroll past these to see what I mean. My org-file is essentially like this. It is part of a bigger file, which I have narrowed to this subtree. * Using org-mode files as databases For example, this code gives me a list of classes that are tagged chemistry|biology|physics|math, and the total units #+BEGIN_SRC emacs-lisp (let* ((total-units 0) (units) (course) (courses (org-map-entries (lambda () (setq units (string-to-number (org-entry-get (point) "UNITS")) total-units (+ total-units units) course (nth 4 (org-heading-components))) `(,course ,units ,(org-entry-get (point) "SEMESTER"))) "chemistry|biology|physics|math" 'tree nil))) (add-to-list 'courses `(nil "Total units" ,total-units) t)) #+END_SRC #+RESULTS: | 09-105 | 9 | 1 | | 09-106 | 9 | 2 | | 33-105 | 12 | 1 | | 33-106 | 12 | 3 | | 21-120 | 9 | 1 | | 21-122 | 9 | 2 | | 21-259 | 9 | 3 | | 03-232 | 9 | 5 | | nil | Total units | 78 | That seems correct. But I noticed that when I run the block, the cursor ends up at the top of the narrowed region at the top headline, and I thought it should stay in the source block since org-map-entries claims to save-excursion. Things get stranger if I add a second source block below this. Here I thought I would get a list of classes with less than 12 UNITS, which are properties. #+BEGIN_SRC emacs-lisp (org-map-entries (lambda () (let ((heading (nth 4 (org-heading-components))) (units (org-entry-get (point) "UNITS"))) `(,heading ,units))) "UNITS<12" 'tree nil) #+END_SRC The results is almost right: #+RESULTS: | Using org-mode files as databases | nil | | 09-105 | 9 | | 09-106 | 9 | | 21-120 | 9 | | 21-122 | 9 | | 21-259 | 9 | | 03-232 | 9 | I was surprised to see the nil in there. I would have thought a heading with no UNITS property would not be included. It is also strange that the results block did not go beneath this source block, but in the first results block from the last example. below this are the headings that are tagged and with properties. Both of those behaviors seem wrong to me. the point does not move in org 7.9.3f, but it does with 8.2.5g. the nil heading shows up in both. So my questions are: 1. is it a new bug that point moves in 8.2.5g? 2. should the headings with no properties be counted as matches? Thanks. ** 09-105 :chemistry: :PROPERTIES: :UNITS: 9 :SEMESTER: 1 :END: ** 09-106 :chemistry: :PROPERTIES: :UNITS: 9 :SEMESTER: 2 :END: ** 33-105 :physics: :PROPERTIES: :UNITS: 12 :SEMESTER: 1 :END: ** 33-106 :physics: :PROPERTIES: :UNITS: 12 :SEMESTER: 3 :END: ** 21-120 :math: :PROPERTIES: :UNITS: 9 :SEMESTER: 1 :END: ** 21-122 :math: :PROPERTIES: :UNITS: 9 :SEMESTER: 2 :END: ** 21-259 :math: :PROPERTIES: :UNITS: 9 :SEMESTER: 3 :END: ** 03-232 :biology: :PROPERTIES: :UNITS: 9 :SEMESTER: 5 :END: ** 06-100 :engineering: :PROPERTIES: :UNITS: 12 :SEMESTER: 1 :END: