emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: B Goodr <bgoodr@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Bug: Org manual: Structure Editing: Clarify commands which use the Transient Mark region [9.3.6 (9.3.6-23-g01ee25-elpaplus @ /tmp/.emacs.d.tmp.99712ad4-61f4-4464-b003-d6d4eea9b98f/org-plus-contrib-20200309/)]
Date: Sun, 15 Mar 2020 11:01:46 -0700	[thread overview]
Message-ID: <CAJj=8EEVXUG0V1Qfr03JtqZWf0+=gD7WPYO=GjoPA+NqyN_PfQ@mail.gmail.com> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 1203 bytes --]

This is not a defect in functionality, only in the documentation
AFAIK. Find attached an Org file I used to tangle up the question
posted at https://emacs.stackexchange.com/q/56155/15483 .  At the time
I posted that question to stackexchange, I thought it was a behavioral
defect or a user-error on my part. Instead, now I think it is
something that needs improvement in the documentation.

The attached Org file launches an emacs -Q session as a child process
with a separate ".emacs.d" with nothing else in it, to guarantee it is
not polluted with my own special config.

The essential issue is this: The paragraph at the very bottom of the
Structure Editing page of the manual is misleading: It leads a user to
believe that all of the commands use the Transient Mark region, but some of
them do not or should not.  One possibility to fix this is to mention,
inside each described command in that page, which ones respect the
region, and which ones do not, possibly using footnotes for more

Thanks to the Org contributors for a wonderful tool!


P.S., OT:L Could not use M-x org-submit-bug-report directly as something is
messed up in my Emacs mail config that I can't fix right now.

[-- Attachment #1.2: Type: text/html, Size: 1403 bytes --]

[-- Attachment #2: OrgModePromoteDemoteMultipleHeadings.org --]
[-- Type: application/octet-stream, Size: 11065 bytes --]

* Org Mode Promote Demote Multiple Headings
  :ID:       91eef3bf-3dfc-4a9b-92f3-1f712d72d5b1
  :tangle-dir: /tmp/org.mode.promote.demote.multiple.headings

** Instructions for use

 1. Define the org-in-tangle-dir function (see that heading below).
 2. Use C-c C-v t, C-c C-v C-t. to tangle this buffer.
 3. Jump down to [[id:99712ad4-61f4-4464-b003-d6d4eea9b98f][runscript]] below and run it.
 4. Go to the tangle-dir property in the top heading and inspect its output (e.g., /tmp/org.mode.promote.demote.multiple.headings/post.txt)

** org-in-tangle-dir

#+NAME: org-in-tangle-dir
#+BEGIN_SRC emacs-lisp :results value :noweb yes :exports none
  ;; Define the function mentioned in: https://emacs.stackexchange.com/a/55859/15483
  ;; I'm not using the usual "bg-" prefix as someday I will want this pushed
  ;; upstream to the org maintainers, so I use "org-" prefix.
  (defun org-in-tangle-dir (sub-path)
    "Return the tangle-dir property from the current point, and use it as the directory to expand SUB-PATH to.
  This is used for tangling in Org files as indicated in https://emacs.stackexchange.com/q/46479/
  If there is no such tangle-dir property in the current tree or any parent, it returns the current
  current org buffers directory."
    (expand-file-name sub-path
		       (org-entry-get (point) "tangle-dir" 'inherit)

** emacs.stackexchange.com post
:ID:       782fa47a-c9a5-4725-90a3-85e124b88b93

Add this to the emacs.stackexchange.com post:

#+BEGIN_SRC text :noweb yes :tangle (org-in-tangle-dir "post.txt") :exports none :mkdirp yes
  # The Problem

  ,**Jump down to Update 1 below for my thoughts as to the chosen answer to this question.**

  I'm using Emacs version <<emacs-version()>> with Org Mode version
  <<org-mode-version()>> installed from Melpa.

  In the Org manual for [Structure Editing][1], I read this:

         When there is an active region - i.e., when Transient Mark mode is
      active - promotion and demotion work on all headlines in the region.  To
      select a region of headlines, it is best to place both point and mark at
      the beginning of a line, mark at the beginning of the first headline,
      and point at the line just after the last headline to change.  Note that
      when point is inside a table (see *note Tables::), the Meta-Cursor keys
      have different functionality.

  But when I make the transient Mark active and set both mark and point
  around more than one heading, type <M-S-left> (`org-shiftmetaleft`),
  it only promotes the first or last heading, depending upon which one
  mark and point are on at the time. I want it to do what I think the
  above implies, and promote all headings in the region. Ditto for
  demoting headings.

  Either this is a defect, or user error. Which is it? See MCVE below for details.

  # MCVE

  Store the following setup.el file into an experiment directory, say, <<experiment-dir()>>

  <!-- language: lang-el -->


  Launch emacs and load the above Elisp file under `-Q` conditions like this:


  This will download the minimal amount of packages to retrieve the
  latest version of Org mode into a scratch directory at
  <<tmp-package-user-dir()>> so you may choose remove that directory

  Add the following lines into a small Org mode file:

      ,* Level 1 heading
      ,** Level 2 heading1
      ,** Level 2 heading2
      ,** Level 2 heading3

  Move point in front of the first asterisk in the "Level 2 heading"
  line. Then use M-h (`org-mark-element`) three times to mark the next
  three headings. Then type <M-S-left> (`org-shiftmetaleft`) and then
  only the first one, "Level 2 heading1", is promoted:

      ,* Level 1 heading
      ,* Level 2 heading1
      ,** Level 2 heading2
      ,** Level 2 heading3

  I tried moving point right after the last "g" in "level 4 heading" and
  it promoted only the last one, ignoring the region completely:

      ,* Level 1 heading
      ,** Level 2 heading1
      ,** Level 2 heading2
      ,* Level 2 heading3

  I've tried all sorts of things and never achieved the goal in this
  case which is to promote all three Level 2 headings into level 1:

      ,* Level 1 heading
      ,* Level 2 heading1
      ,* Level 2 heading2
      ,* Level 2 heading3

  https://emacs.stackexchange.com/a/54301/15483 seems to imply that it
  should work and I have something broken in my org mode or something.

  # Update 1

  If you look inside [Structure Editing][1] only see this:

      ‘M-<LEFT>’ (‘org-do-promote’)
           Promote current heading by one level.

      ‘M-<RIGHT>’ (‘org-do-demote’)
           Demote current heading by one level.

      ‘M-S-<LEFT>’ (‘org-promote-subtree’)
           Promote the current subtree by one level.

      ‘M-S-<RIGHT>’ (‘org-demote-subtree’)
           Demote the current subtree by one level.

    The last paragraph I quoted at the top of this question does not
  indicate the scope of commands that respect the marked region. That
  led me to conclude the region applies to them all, which is not the
  case.  Thus, the answer at
  https://emacs.stackexchange.com/a/56157/15483 is the correct answer.

  I consider this to be a defect in the Org Manual, not in the behavior:
  This question will be out of date with new manuals if/when this defect
  is fixed.

    [1]: https://orgmode.org/manual/Structure-Editing.html#Structure-Editing

** test-org-file
:ID:       ca2207e9-f3ce-40e7-b184-af53bac9c4d7

#+NAME: test-org-file
#+BEGIN_SRC text :noweb yes :tangle (org-in-tangle-dir "test.org") :exports none :mkdirp yes
  ,* Level 1 heading
  ,** Level 2 heading1
  ,** Level 2 heading2
  ,** Level 2 heading3

** experiment-dir

#+NAME: experiment-dir
#+BEGIN_SRC emacs-lisp :results value :noweb yes :exports none :var experiment_dir=(org-entry-get (point) "tangle-dir" 'inherit)

** tmp-package-user-dir

#+NAME: tmp-package-user-dir
#+BEGIN_SRC emacs-lisp :results value :noweb yes :exports none

** emacs-lisp-file
:ID:       5555868b-171e-48f5-89c8-01851c5b913f

#+NAME: setup
#+BEGIN_SRC emacs-lisp :results output :noweb yes :tangle (org-in-tangle-dir "setup.el") :exports none :mkdirp yes
  (defun my-use-package-setup ()

    ;; Derived from
    ;; https://github.com/chrispoole643/etc/blob/master/emacs/.emacs.d/init.el
    ;; referenced by
    ;; https://www.reddit.com/r/emacs/comments/5sx7j0/how_do_i_get_usepackage_to_ignore_the_bundled/
    ;; Define org and melpa as package sources, and install `use-package' if it's not
    ;; already there. Always ensure packages being loaded are there (or else it'll
    ;; automatically download from melpa)
    ;; I don't want to do it this way, as it is org-mode specific. This ordering and
    ;; prioritization has to happen before all use of use-package. Without this,
    ;; we run the risk of some other package we require pulling in the stock
    ;; version of Org mode shipped with Emacs, when we only want the latest
    ;; version.
    (require 'package)

    ;; For this MCVE, I _have_ to set package-user-dir below in order to keep my
    ;; installation separate from the normal one, so as to prove that I am only
    ;; installing the minimum set of packages to reproduce the issue for the MCVE:
    (setq package-user-dir (expand-file-name "<<tmp-package-user-dir()>>"))

    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
    (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
    ;; Ensure that "org" and "melpa" are found first in this order (higher numbers are higher priority):
    (setq package-archive-priorities '(("org" . 3)
                                       ("melpa" . 2)
                                       ("gnu" . 1)))
    ;; This is the key!! -->  " The symbol ‘all’ says to load the latest installed
    ;; versions of all packages not specified by other elements." and for org-mode, this means always get that latest version.
    (setq package-load-list '(all))

    ;; Not sure why we need this:
    (setq package-enable-at-startup nil)

    ;; Install use-package unconditionally. For some reason the existing
    ;; use-package version failed so we have to waste initialization time doing it
    ;; every time, and cannot use this:
    ;;   ;; Install use-package:
    ;;   (unless (package-installed-p 'use-package)
    ;;     (message "Installing use-package")
    ;;     (package-refresh-contents)
    ;;     (package-install 'use-package))
    ;; Reason is unknown.
    (package-install 'use-package)

    ;; Require use-package:
    (require 'use-package)

    ;; Load org mode early to ensure that the latest org mode version gets picked up, not the
    ;; shipped version.
    ;;   Reference https://github.com/jwiegley/use-package#package-installation
    (require 'use-package-ensure)
    (setq use-package-always-ensure t))

  ;; Get the package ordering and priority for using use-package:
  ;;   Unfortunately, order does matter here: We have to do this setup _before_
  ;;   any and all use of use-package.

  ;; Get the org package:
  (use-package org
    ;; Install both org and "contrib"-uted org-related packages:
    ;;    See https://tinyurl.com/y2gt69kj that indicates that org-plus-contrib
    ;;    seems to be some sort of "mashup" package, that includes both org itself
    ;;    and the so-called "contrib" packages. I'm not sure which ones of those
    ;;    contrib packages I actually use so just grab them all.
    :ensure org-plus-contrib
    :pin org)


** emacs-version block

#+NAME: emacs-version
#+BEGIN_SRC emacs-lisp
  ;; (emacs-version) function returns a lot of extra info whereas I just need the version number in the emacs-version variable:
** org-mode-version block

#+NAME: org-mode-version
#+BEGIN_SRC emacs-lisp
  ;; (org-version) only returns the version number
** runscript
:ID:       99712ad4-61f4-4464-b003-d6d4eea9b98f

#+NAME: runscript
#+BEGIN_SRC bash :results output :noweb yes :tangle (org-in-tangle-dir "runscript") :exports none :mkdirp yes :shebang "#!/bin/bash"

  exec 2>&1
  set -x
  nohup emacs -Q \
         --debug-init \
         --load $experiment_dir/setup.el \


#+RESULTS: runscript
: + experiment_dir=/tmp/org.mode.promote.demote.multiple.headings
: + sleep 1
: + nohup emacs -Q --debug-init --load /tmp/org.mode.promote.demote.multiple.headings/setup.el /tmp/org.mode.promote.demote.multiple.headings/test.org

             reply	other threads:[~2020-03-15 18:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-15 18:01 B Goodr [this message]
2020-03-15 21:11 ` Bug: Org manual: Structure Editing: Clarify commands which use the Transient Mark region [9.3.6 (9.3.6-23-g01ee25-elpaplus @ /tmp/.emacs.d.tmp.99712ad4-61f4-4464-b003-d6d4eea9b98f/org-plus-contrib-20200309/)] Kyle Meyer
2020-03-15 23:50   ` B Goodr
2020-03-18  3:43   ` Kyle Meyer
2020-03-25 15:54     ` B Goodr
2020-03-26  1:46       ` Kyle Meyer
2020-03-26 17:29         ` B Goodr

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:

  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='CAJj=8EEVXUG0V1Qfr03JtqZWf0+=gD7WPYO=GjoPA+NqyN_PfQ@mail.gmail.com' \
    --to=bgoodr@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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


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).