emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Fraga, Eric" <e.fraga@ucl.ac.uk>
To: "Michaël Cadilhac" <michael@cadilhac.name>
Cc: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Scheduling in a narrowed subtree: Bug?
Date: Tue, 10 Sep 2019 07:53:51 +0000	[thread overview]
Message-ID: <87o8zsk2nm.fsf@ucl.ac.uk> (raw)
In-Reply-To: CADt3fpN2pLynn+ZpWgJ7ZUjafcyZ1_QmecPvw3VweC_iVXzthg@mail.gmail.com

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

  parent reply	other threads:[~2019-09-10  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 20:17 Scheduling in a narrowed subtree: Bug? Michaël Cadilhac
2019-09-09 22:13 ` Gustavo Barros
2019-09-10  7:53 ` Fraga, Eric [this message]
2019-09-10 21:10 ` Gustavo Barros
2020-05-06  0:44 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8zsk2nm.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael@cadilhac.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).