all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* adding subheadings
@ 2007-07-15 19:07 Adam Spiers
  2007-07-15 23:42 ` Adam Spiers
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Adam Spiers @ 2007-07-15 19:07 UTC (permalink / raw)
  To: org-mode mailing list

Hi all,

First post so go easy on me ;-)

Would something like the following be of use to anyone other than me?
(Suggested key-bindings at the bottom of the code.)

--------- 8< --------- 8< --------- 8< --------- 8< --------- 8< ---------
(defun org-new-subheading ()
  "Add a new heading, demoted from the current heading level."
  (interactive)
  (org-insert-heading)
  (org-demote-subtree))

(defun org-new-subheading-todo (&optional arg)
  "Add a new TODO item, demoted from the current heading level.

The TODO keyword for the new item can be specified by a numeric
prefix argument, as with `org-todo'.

Otherwise, if `org-subheading-todo-alist' is non-nil, it is used
to map the new keyword from the current one, and if it is nil,
the next TODO keyword in the sequence is used, or the first one
if the current heading does not have one.

This allows a TODO keyword hierarchy to be imposed, e.g.
if org-subheading-todo-alist is

  '((\"MASTERPLAN\" . \"PROJECT\")
    (\"PROJECT\"    . \"NEXTACTION\")
    (\"NEXTACTION\" . \"NEXTACTION\"))

then invoking this function four times would yield:

* MASTERPLAN
** PROJECT
*** NEXTACTION
**** NEXTACTION"
  (interactive "P")
  (save-excursion
    (org-back-to-heading)
    (looking-at org-todo-line-regexp))
  (let* ((current-keyword (match-string 2))
         (new-keyword
          (if arg
              (nth (1- (prefix-numeric-value arg))
                   org-todo-keywords-1)
            (or
             (and current-keyword
                  (or (car (assoc current-keyword org-subheading-todo-alist))
                      (cadr (member current-keyword org-todo-keywords-1))))
             (car org-todo-keywords-1)))))
    (org-new-subheading)
    (insert new-keyword " ")))

(defcustom org-subheading-todo-alist nil
  "An associative map to help define which TODO keyword should be
used for new subheadings, depending on the current heading's TODO
keyword.  See the documentation for `org-new-subheading-todo' for
an example."
  :group 'org-todo
  :type '(alist :key-type   (string :tag "Current heading keyword")
                :value-type (string :tag "New sub-heading keyword")))

(org-defkey org-mode-map [(meta j)]       'org-new-subheading)
(org-defkey org-mode-map [(shift meta j)] 'org-new-subheading-todo)
--------- 8< --------- 8< --------- 8< --------- 8< --------- 8< ---------

I would have preferred to make the defcustom have a radio button list
of existing TODO keywords for the alist keys and values, rather than
freeform strings, but I couldn't figure out how to get it to refer to
to org-todo-keywords-1.

Finally, what's the preferred way to submit patches?  Is there a
revision-controlled repository available anywhere?

Cheers,
Adam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: adding subheadings
  2007-07-15 19:07 adding subheadings Adam Spiers
@ 2007-07-15 23:42 ` Adam Spiers
  2007-07-17 20:58 ` Scott Jaderholm
  2007-08-12  6:31 ` Carsten Dominik
  2 siblings, 0 replies; 5+ messages in thread
From: Adam Spiers @ 2007-07-15 23:42 UTC (permalink / raw)
  To: emacs-orgmode

Adam Spiers (orgmode@adamspiers.org) wrote:
> (defun org-new-subheading ()
>   "Add a new heading, demoted from the current heading level."
>   (interactive)
>   (org-insert-heading)
>   (org-demote-subtree))
         ^^^^^^^^^^^^^^

Sorry, that should be org-do-demote.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: adding subheadings
  2007-07-15 19:07 adding subheadings Adam Spiers
  2007-07-15 23:42 ` Adam Spiers
@ 2007-07-17 20:58 ` Scott Jaderholm
  2007-07-20 16:53   ` Adam Spiers
  2007-08-12  6:31 ` Carsten Dominik
  2 siblings, 1 reply; 5+ messages in thread
From: Scott Jaderholm @ 2007-07-17 20:58 UTC (permalink / raw)
  To: Adam Spiers; +Cc: org-mode mailing list

Hi Adam,

On 7/15/07, Adam Spiers <orgmode@adamspiers.org> wrote:
> First post so go easy on me ;-)

Thanks!

> Would something like the following be of use to anyone other than me?

Definitely! The general purpose part (inserting subheadings/subtodos)
is useful to me, but I don't have a TODO keywords hierarchy so the
chaining isn't personally useful.

> (Suggested key-bindings at the bottom of the code.)

M-j is an intuitive choice, but M-j is also nice for following
headlines with plain lists that are indented correctly. It's going to
be hard to decide which to go with.

I used your code how it is and expected to get
* TODO Something
** TODO Something

and running (setq org-subheading-todo-alist '((\"TODO\" . \"TODO\")))
didn't give me the expected behavior. Is there something I'm missing?

Thanks again for the code,
Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: adding subheadings
  2007-07-17 20:58 ` Scott Jaderholm
@ 2007-07-20 16:53   ` Adam Spiers
  0 siblings, 0 replies; 5+ messages in thread
From: Adam Spiers @ 2007-07-20 16:53 UTC (permalink / raw)
  To: org-mode mailing list

On Tue, Jul 17, 2007 at 02:58:59PM -0600, Scott Jaderholm wrote:
> >Would something like the following be of use to anyone other than me?
> 
> Definitely! The general purpose part (inserting subheadings/subtodos)
> is useful to me, but I don't have a TODO keywords hierarchy so the
> chaining isn't personally useful.
> 
> >(Suggested key-bindings at the bottom of the code.)
> 
> M-j is an intuitive choice, but M-j is also nice for following
> headlines with plain lists that are indented correctly. It's going to
> be hard to decide which to go with.

Hmm, well S-return seems to be org-table-copy-down at the moment.
Surely we could overload that?

> I used your code how it is and expected to get
> * TODO Something
> ** TODO Something
> 
> and running (setq org-subheading-todo-alist '((\"TODO\" . \"TODO\")))
> didn't give me the expected behavior. Is there something I'm missing?

The quotes don't look right there, should it be

  (setq org-subheading-todo-alist '(("TODO" . "TODO")))

?  What behavior do you see?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: adding subheadings
  2007-07-15 19:07 adding subheadings Adam Spiers
  2007-07-15 23:42 ` Adam Spiers
  2007-07-17 20:58 ` Scott Jaderholm
@ 2007-08-12  6:31 ` Carsten Dominik
  2 siblings, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2007-08-12  6:31 UTC (permalink / raw)
  To: Adam Spiers; +Cc: org-mode mailing list

org-insert-subheading and org-insert-todo-subheading
will be in 5.05, and work both for headings and for plain list items.

I did not implement the TODO hierarchy, that seems not something
that will be used generally.  You can hack it back in by adding
a function to the hook org-insert-heading-hook, which seems
to be the perfect place for a customization like this.

There is no keybinding for these commands yet.

Thanks!.

- Carsten

On Jul 15, 2007, at 21:07, Adam Spiers wrote:

> Hi all,
>
> First post so go easy on me ;-)
>
> Would something like the following be of use to anyone other than me?
> (Suggested key-bindings at the bottom of the code.)
>
> --------- 8< --------- 8< --------- 8< --------- 8< --------- 8< 
> ---------
> (defun org-new-subheading ()
>   "Add a new heading, demoted from the current heading level."
>   (interactive)
>   (org-insert-heading)
>   (org-demote-subtree))
>
> (defun org-new-subheading-todo (&optional arg)
>   "Add a new TODO item, demoted from the current heading level.
>
> The TODO keyword for the new item can be specified by a numeric
> prefix argument, as with `org-todo'.
>
> Otherwise, if `org-subheading-todo-alist' is non-nil, it is used
> to map the new keyword from the current one, and if it is nil,
> the next TODO keyword in the sequence is used, or the first one
> if the current heading does not have one.
>
> This allows a TODO keyword hierarchy to be imposed, e.g.
> if org-subheading-todo-alist is
>
>   '((\"MASTERPLAN\" . \"PROJECT\")
>     (\"PROJECT\"    . \"NEXTACTION\")
>     (\"NEXTACTION\" . \"NEXTACTION\"))
>
> then invoking this function four times would yield:
>
> * MASTERPLAN
> ** PROJECT
> *** NEXTACTION
> **** NEXTACTION"
>   (interactive "P")
>   (save-excursion
>     (org-back-to-heading)
>     (looking-at org-todo-line-regexp))
>   (let* ((current-keyword (match-string 2))
>          (new-keyword
>           (if arg
>               (nth (1- (prefix-numeric-value arg))
>                    org-todo-keywords-1)
>             (or
>              (and current-keyword
>                   (or (car (assoc current-keyword 
> org-subheading-todo-alist))
>                       (cadr (member current-keyword 
> org-todo-keywords-1))))
>              (car org-todo-keywords-1)))))
>     (org-new-subheading)
>     (insert new-keyword " ")))
>
> (defcustom org-subheading-todo-alist nil
>   "An associative map to help define which TODO keyword should be
> used for new subheadings, depending on the current heading's TODO
> keyword.  See the documentation for `org-new-subheading-todo' for
> an example."
>   :group 'org-todo
>   :type '(alist :key-type   (string :tag "Current heading keyword")
>                 :value-type (string :tag "New sub-heading keyword")))
>
> (org-defkey org-mode-map [(meta j)]       'org-new-subheading)
> (org-defkey org-mode-map [(shift meta j)] 'org-new-subheading-todo)
> --------- 8< --------- 8< --------- 8< --------- 8< --------- 8< 
> ---------
>
> I would have preferred to make the defcustom have a radio button list
> of existing TODO keywords for the alist keys and values, rather than
> freeform strings, but I couldn't figure out how to get it to refer to
> to org-todo-keywords-1.
>
> Finally, what's the preferred way to submit patches?  Is there a
> revision-controlled repository available anywhere?
>
> Cheers,
> Adam
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-12  6:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-15 19:07 adding subheadings Adam Spiers
2007-07-15 23:42 ` Adam Spiers
2007-07-17 20:58 ` Scott Jaderholm
2007-07-20 16:53   ` Adam Spiers
2007-08-12  6:31 ` Carsten Dominik

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.