From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] Org document concept + document property drawers Date: Sun, 01 Sep 2019 12:38:11 +0200 Message-ID: <87o904qp2k.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4NFS-0004b3-On for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 06:38:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4NFR-0004WY-4V for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 06:38:18 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:42029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i4NFQ-0004Ph-Ra for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 06:38:17 -0400 In-Reply-To: ("Gustav =?utf-8?Q?Wikstr=C3=B6m=22's?= message of "Sat, 31 Aug 2019 18:49:42 +0000") 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: Gustav =?utf-8?Q?Wikstr=C3=B6m?= Cc: Carsten Dominik , "emacs-orgmode@gnu.org" Hello, Gustav Wikstr=C3=B6m writes: > I'm continuing on my proposal to introduce a "document" element in > org-mode and the idea of seeing everything before the first headline > as the base level 0 outline for a file. I've attached two patches that > I'd like some public review of before pushing to master. I will not review fully the patches, as I have no time for that. However, I will make a few comments about it. First, you should show a few examples of what an Org document would look like, compared to what we have already, focusing particularly on the advantages, and what is now invalid. It is a good thing to do if you expect comments, as you cannot ask everyone to eyeball through the whole patch set. Also, whatever the outcome of the discussion is, /nothing should go in master as long as Org 9.3 is not released/. This looks like a breaking change at the most lower level (syntax, parser...), I think it may trigger a new major release. > Patch 0001 introduces the document element into org-element.el, and > some restructuring related to that. This should be explained in comments, and, if it lands at some point, Worg pages about syntax and exporter should be updated, too. > ** (renamed, modified) org--setup-collect-keywords -> org-collect-keywords > Renamed and generalized org--setup-collect-keywords to make it work > for multiple purposes. Is not limited to a fixed set of keywords any > longer. New name: org-collect-keywords. An important typo note: we use "Org mode", or "an Org document", not "Org-mode" and "an org-document". Hyphens are only used to refer explicitly to a Lisp symbol, or its value or function. > ** (modified) org-element-keyword-parser > Uses (new) org-keyword-regexp instead of hardcoding it's own regexp. Keep in mind that Org Element library should ultimately be as independent as possible to the other parts of Org, including "org.el". > +;; Org-element can parse org-mode documents. The top-node in the > +;; parse-tree will always have TYPE `org-data' and PROPERTIES nil. See my remark about typography above. > +;; The following part creates a fully recursive org-mode parser.=20=20 Ditto. > +(defun org-back-to-heading-or-point-min (&optional invisible-ok) > + "Go back to heading or first point in buffer. > +If point is before first heading go to first point in buffer > +instead of back to heading." > + (condition-case nil > + (outline-back-to-heading invisible-ok) > + (error > + (goto-char (point-min))))) Try to limit use of Outline functions. They are generally slower than their Org counterpart. This is not true in this case, but, one day, we might optimize `org-back-to-heading'. > +(defun org-at-keyword-p nil > + "Is cursor at a keyword-line?" Non-nil if ... > + (save-excursion > + (move-beginning-of-line 1) > + (looking-at org-keyword-regexp))) While this is technically correct today, please don't write a predicate only based on regexps, use the parser for that. For example, the parser can understand #+begin_example #+keyword: not a keyword #+end_example whereas your function cannot. Also, you could use `org-match-line' in this case. Regards, --=20 Nicolas Goaziou