From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: whether in drawer? Date: Thu, 28 Apr 2016 12:43:14 -0700 Message-ID: References: <87wpnh3hw1.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avrqH-0001S4-EV for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 15:43:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avrqG-00041u-73 for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 15:43:17 -0400 Received: from mail-yw0-x232.google.com ([2607:f8b0:4002:c05::232]:35925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avrqG-00041p-1y for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 15:43:16 -0400 Received: by mail-yw0-x232.google.com with SMTP id o66so140762083ywc.3 for ; Thu, 28 Apr 2016 12:43:15 -0700 (PDT) In-Reply-To: <87wpnh3hw1.fsf@alphapapa.net> 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: Adam Porter Cc: emacs-orgmode@gnu.org On 4/28/16, Adam Porter wrote: > Do you have any other posts talking about this? I'm interested in > fixing this too. I've run into situations occasionally where undo-tree > seems to try to operate on a region or a hidden/folded area, and it just > kind of goes bonkers, and I end up having to revert the buffer. It > would be nice to fix this. i proposed org visibility to the author of undo-tree, who did not use org at the time (but might be on this list). one suggestion i made was that undo-tree could undo and redo visibility changes as it goes about its normal operation. he thought this would require an emacs change. we cross-posted it. stefan said it wouldn't require an emacs change, but org could put visibility state information into the undo list. this is intriguing. dunno if it is feasible. === an alternative is to do what i did, kludge undo-tree with hideous, grotesque, misshapen defadvice that looks like something your cat dragged in. the following is unsightly, horror-filled code written over many years a few minutes at a time, which works for most cases. undo-tree still shows too much and confuses me after sorting, and closes drawers when undoing, and sometimes does not show the change if you do an undo and then a redo (it is supposed to because it is supposed to be asymmetric in point placement). btw, possibly outside the scope of undo-tree and org visibility, org has a few glitches where no change shows up as a change. there are also a few slightly disconcerting but pretty harmless cases where undo-boundary is set for compound operations like checkbox cookie updating. again probably in org, but maybe in undo-tree, and probably outside the scope of visibility, there are also cases, at least with logbook entries, in which you can make two separate changes to separate tasks, and cannot undo only one of them because there is no undo boundary between them. this violates the hoary old principle of "user expectation that you can undo what you did without undoing anything else". i have turned off agenda undo features, so i think it occurs with normal operation in org. perhaps logbook updating has post-command-hook fanciness that changes undo behavior? just a guess. those i did not attempt to fix. i am not capable of it. i include the following monstrous insult to programmer-kind (i am a mere user, as if /that's/ an excuse) with glorious comments for your amusement. (defadvice undo-tree-undo (after org-undo-reveal activate compile) "Make point and context visible after an undo command in org-mode." (alpha-org-reveal-for-undo)) ;; ;; ;;might be nec, perhaps because undo tree moves point to ;; ;; ;;other change (defadvice undo-tree-redo (after org-redo-reveal activate compile) "Make point and context visible after an undo command in org-mode." (alpha-org-reveal-for-undo)) (defun alpha-org-reveal-for-undo () ;; maybe we want seiza canonical if on header, else canonical (save-excursion (when (eq major-mode 'org-mode) (unless (eq last-command this-command) ;; '(undo-tree-undo ;; undo-tree-redo ;; ;; self-insert-command ;; ;; org-self-insert-command ;; ;; org-shiftmetadown ;; ;; org-shiftmetaup ;; )) (unless (or (org-at-heading-p) ;; in drawer ) (alpha-hide-parent)) ;; (org-show-entry) ;; (org-overview) ;; (recenter) ;; (if (org-at-heading-p) ;; (save-excursion ;; (forward-line 1) ;; (org-show-set-visibility 'canonical)) ;; ;; this creates ellipsis if on headline (org-show-set-visibility 'canonical) ;; (when (org-in-drawer-p) org-flag-drawer nil ;; get rid of that !@#$!@#$ ellipsis at top of window ;; fixme still need to do this after org-cycle (scroll-lock-previous-line) (scroll-lock-next-line) )) (when (org-truely-invisible-p) (org-show-set-visibility 'canonical)) ;; notwork ;; (save-excursion ;; (move-to-window-line 1) ;; (redisplay)) )) ;; (when (org-at-heading-p) ;; ;; (when (outline-invisible-p) ;; '(org-reveal t) ;; (org-show-set-visibility 'canonical)) ;; ;; (when (eq last-command 'alpha-org-sort-siblings) ;; (alpha-org-show-children-and-entry)))) ;;(ad-unadvise 'undo) ;; elsewhere (setq org-self-insert-cluster-for-undo nil)