emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Scheduling in a narrowed subtree: Bug?


From: Fraga, Eric
Subject: Re: [O] Scheduling in a narrowed subtree: Bug?
Date: Tue, 10 Sep 2019 07:53:51 +0000

On Monday,  9 Sep 2019 at 15:17, Michaël Cadilhac wrote:
> Is this the expected behavior?
>
> 1. Create an empty org file
> 2. Insert
> * Test
> * Test 2
> 3. With the cursor at Test, hit C-x n s to narrow the view to the Test
> subtree
> 4. Hit C-c C-s to schedule the line at any date.
>
> As a result, the SCHEDULED keyword is _not_ included in the narrow view,
> and inserting things after the Test heading moves the SCHEDULED keyword
> away from its second-line position.

I can confirm this.

However, normally, I do not use narrowing to subtree but instead use a
function based on the code originally from

http://endlessparentheses.com/emacs-narrow-or-widen-dwim.html

My code looks like this:

#+begin_src org
  (defun narrow-or-widen-dwim (p)
    "Widen if buffer is narrowed, narrow-dwim otherwise.
  Dwim means: region, org-src-block, org-subtree, or defun,
  whichever applies first. Narrowing to org-src-block actually
  calls `org-edit-src-code'.

  With prefix P, don't widen, just narrow even if buffer is
  already narrowed."
    (interactive "P")
    (declare (interactive-only))
    (cond ((and (buffer-narrowed-p) (not p)) (widen))
          ((region-active-p)
           (narrow-to-region (region-beginning) (region-end)))
          ((derived-mode-p 'org-mode)
           ;; `org-edit-src-code' is not a real narrowing
           ;; command. Remove this first conditional if you
           ;; don't want it.
           (cond ((ignore-errors (org-edit-src-code))
                  (delete-other-windows))
                 ((ignore-errors (org-narrow-to-block) t))
                 ((ignore-errors (org-narrow-to-element) t))
                 (t (org-narrow-to-subtree))))
          ((derived-mode-p 'latex-mode)
           (LaTeX-narrow-to-environment))
          (t (narrow-to-defun))))
#+end_src

This tries a number of different narrowing functions first.  Using
this, everything works fine.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.4-401-gfabd6d

reply via email to

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