[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] whether in drawer?

From: Samuel Wales
Subject: Re: [O] whether in drawer?
Date: Thu, 28 Apr 2016 12:43:14 -0700

On 4/28/16, Adam Porter <address@hidden> 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

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

(defadvice undo-tree-undo (after org-undo-reveal activate compile)
  "Make point and context visible after an undo command in org-mode."
;; ;; ;;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."
(defun alpha-org-reveal-for-undo ()
  ;; maybe we want seiza canonical if on header, else canonical
    (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
        ;; (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 address@hidden@#$ ellipsis at top of window
        ;;   fixme still need to do this after org-cycle
    (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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]