From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: [bug] canonical context not work in 8.3 Date: Sun, 9 Aug 2015 11:53:16 -0700 Message-ID: References: <87mvy4eywo.fsf@nicolasgoaziou.fr> <8737zvfpvc.fsf@nicolasgoaziou.fr> <87y4hmb3vb.fsf@nicolasgoaziou.fr> <87mvy2b0i5.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOVig-0006Vb-He for emacs-orgmode@gnu.org; Sun, 09 Aug 2015 14:53:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOVif-0005ER-EH for emacs-orgmode@gnu.org; Sun, 09 Aug 2015 14:53:18 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:36841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOVif-0005EJ-6Z for emacs-orgmode@gnu.org; Sun, 09 Aug 2015 14:53:17 -0400 Received: by wicja10 with SMTP id ja10so14134557wic.1 for ; Sun, 09 Aug 2015 11:53:16 -0700 (PDT) In-Reply-To: <87mvy2b0i5.fsf@nicolasgoaziou.fr> 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: Samuel Wales , emacs-orgmode thank you. this version is significantly faster. qualitatively improved. it has a possibly minor bug. evalled as source: - command-execute 8072 98% - call-interactively 8072 98% - org-agenda-switch-to 7595 92% - org-show-context 7595 92% - org-show-set-visibility 7595 92% - show-children 7039 86% - save-excursion 7015 85% - let* 7015 85% - while 4832 59% - outline-flag-region 692 8% remove-overlays 12 0% - save-excursion 2179 26% org-end-of-subtree 2179 26% - funcall 4 0% org-outline-level 4 0% however, if the next heading has fewer stars, it errors: Debugger entered--Lisp error: (invalid-regexp "Invalid content of \\{\\}") re-search-forward("^\\*\\{27,13\\} +" 2473493 t) (while (re-search-forward re end t) (outline-flag-region (line-end-position 0) (line-end-position) nil)) (let* ((current-level (funcall outline-level)) (level (if level (+ (prefix-numeric-value level) current-level) (save-excursion (outline-next-heading) (if (eobp) current-level (funcall outline-level))))) (re (format "^\\*\\{%d,%d\\} +" current-level level)) (end (save-excursion (org-end-of-subtree t t)))) (while (re-search-forward re end t) (outline-flag-region (line-end-position 0) (line-end-position) nil))) (save-excursion (org-back-to-heading t) (let* ((current-level (funcall outline-level)) (level (if level (+ (prefix-numeric-value level) current-level) (save-excursion (outline-next-heading) (if (eobp) current-level (funcall outline-level))))) (re (format "^\\*\\{%d,%d\\} +" current-level level)) (end (save-excursion (org-end-of-subtree t t)))) (while (re-search-forward re end t) (outline-flag-region (line-end-position 0) (line-end-position) nil)))) show-children() org-show-set-visibility(canonical) org-show-context(agenda) org-agenda-switch-to() call-interactively(org-agenda-switch-to nil nil) command-execute(org-agenda-switch-to) (defun show-children (&optional level) (save-excursion (org-back-to-heading t) (let* ((current-level (funcall outline-level)) (level (if level (+ (prefix-numeric-value level) current-level) (save-excursion (outline-next-heading) (if (eobp) current-level (funcall outline-level))))) (re (format "^\\*\\{%d,%d\\} +" current-level level)) (end (save-excursion (org-end-of-subtree t t)))) (while (re-search-forward re end t) (outline-flag-region (line-end-position 0) (line-end-position) nil))))) On 8/8/15, Nicolas Goaziou wrote: > This one may improve the situation: