From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: One broken property drawer prevents setting of any property Date: Fri, 23 May 2014 16:55:26 +0800 Message-ID: <87k39cnabl.fsf@ericabrahamsen.net> References: <87wqdzebq0.fsf@ericabrahamsen.net> <87k39df36v.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnlD7-00068u-6x for emacs-orgmode@gnu.org; Fri, 23 May 2014 04:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnlD0-0001iT-KL for emacs-orgmode@gnu.org; Fri, 23 May 2014 04:52:17 -0400 Received: from mail-yk0-f180.google.com ([209.85.160.180]:38976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnlD0-0001iG-Fg for emacs-orgmode@gnu.org; Fri, 23 May 2014 04:52:10 -0400 Received: by mail-yk0-f180.google.com with SMTP id q9so3728324ykb.25 for ; Fri, 23 May 2014 01:52:09 -0700 (PDT) In-Reply-To: <87k39df36v.fsf@bzg.ath.cx> (Bastien's message of "Fri, 23 May 2014 07:56:40 +0200") 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 Cc: Bastien , Nicolas Goaziou --=-=-= Content-Type: text/plain Bastien writes: > Hi Eric, > > Eric Abrahamsen writes: > >> By passing the FORCE argument to `org-get-property-block', the broken >> block ends up getting silently repaired, and everything works as normal. > > Can you show this as a patch? > >> I'm not sure, however, that silently repairing things without the user's >> knowledge is the right thing to do... > > We can warn the user with a temporary message, or ask him for > confirmation. Or provide a helper command to repair drawers and > advertize it instead of throwing an error. > > I'll look into this after you send me the patch. The more I thought about it, the more it seemed the silent repair is a bad idea: it's not really repair, it's just sticking a new :END: in, and will very likely result in cruft in the buffer. This patch wraps the scan in catch/throw and asks users if they want to repair broken drawers. Since the y-or-no-p stops at the broken drawer, it should be useful for manual fixing. E --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Warn-users-of-malformed-property-drawers.patch >From 3995f4816ba400f5c7645f84b5dcf7e84698d604 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Fri, 23 May 2014 16:52:58 +0800 Subject: [PATCH] Warn users of malformed property drawers org.el (org-buffer-property-keys): When scanning the buffer for valid property keys, give users a chance to repair any malformed property drawers. --- lisp/org.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b16515e..a3f0cba 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15712,12 +15712,17 @@ formats in the current buffer." (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) - (setq range (org-get-property-block)) - (goto-char (car range)) - (while (re-search-forward org-property-re - (cdr range) t) - (add-to-list 'rtn (org-match-string-no-properties 2))) - (outline-next-heading)))) + (catch 'cont + (setq range (or (org-get-property-block) + (if (y-or-n-p + (format "Malformed drawer at %d, repair?" (point))) + (org-get-property-block nil nil t) + (throw 'cont nil)))) + (goto-char (car range)) + (while (re-search-forward org-property-re + (cdr range) t) + (add-to-list 'rtn (org-match-string-no-properties 2))) + (outline-next-heading))))) (when include-specials (setq rtn (append org-special-properties rtn))) -- 1.9.3 --=-=-=--