emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Using orgstruct-mode (or just org-cycle) in emacs-lisp-mode
Date: Tue, 01 Dec 2015 21:06:07 +0100	[thread overview]
Message-ID: <87vb8i0w9c.fsf@gmail.com> (raw)
In-Reply-To: 87k2pqvj1i.fsf@bernoul.li

Jonas Bernoulli <jonas@bernoul.li> writes:

Hi List,

> Aaron Ecay <aaronecay@gmail.com> writes:
>
>> Thorsten Jolitz wrote the outshine library
>
> I know. I used it for a while and contributed a few commits.  But I
> pretty much only used the cycling functionality at the time and when
> I discovered that `org-cycle' worked for that too, I stopped using
> outshine.  It also felt a bit like re-inventing the wheel.
>
>> Sadly it’s not actively maintained ATM, but I believe it still works
>> fine,

When I was a heavy outshine user myself it was feature rich and very
stable, and I think it still should be.  So being unmaintained does not
mean you can or should not use it, it only means that I did not add any
new features the last year (and sometimes miss a bug report,
unfortunately). But the three libraries of the outshine-suite
(outshine.el, outorg.el and navi-mode.el) already have so many features
that even the main author could not remember all of them ...

> That's a bit of an understatement; if I remember correctly Thorsten
> stopped using Emacs.

Its true that events in my life kicked me out of the (enjoyable) Emacs
universe, but now I actually use Emacs again once in a while, and hope
more frequently in the future.

>> and it may be an alternative route towards the features you are
>> looking for.
>
> Well currently I am just using `org-cycle' + `outline-minor-mode', which
> works well enough for now.  But eventually I would like to also start
> using Org's navigational commands.  Unfortunately `orgstruct-mode' only
> supports org-like headings (;; * heading\n;; ** subheadng) and not
> standard Emacs headings (;;; heading\n;;;; subheading).  I hope someone
> teaches `orgstruct-mode' to support the latter too.  Otherwise I will
> probably give `outshine' another chance.

When there are problems with orgstruct - while waiting for a new
implementation based on outline-minor-mode, why not use an existing,
much more powerfull and very stable alternative based on
outline-minor-mode?

When writing an org-minor-mode (orgstruct, outshine, ...) the most
frequent FAQ is by definition:

"I want Org-mode feature XYZ in org-minor-mode too."

The org-minor-mode author then figures out quickly that

 - Org-mode is not a library engineered for reuse by other
   applications. Org functions do many things, and its often hard or
   impossible to just call them for a result or even copy&paste them
   for reuse.
 - he does not want to rewrite Org-mode

My solution for outshine was 

,----[ C-h f outshine-use-outorg RET ]
| outshine-use-outorg is a Lisp function in `outshine.el'.
| 
| (outshine-use-outorg FUN &optional WHOLE-BUFFER-P &rest FUNARGS)
| 
| Use outorg to call FUN with FUNARGS on subtree or thing at point.
| 
| FUN should be an Org-mode function that acts on the subtree or
| org-element at point. Optionally, with WHOLE-BUFFER-P non-nil,
| `outorg-edit-as-org' can be called on the whole buffer.
| 
| Sets the variable `outshine-use-outorg-last-headline-marker' so
| that it always contains a point-marker to the last headline this
| function was called upon.
`----

With this function potentially all Org-mode commands can easily be made
available in outshine. In practise, some Org functions are really tricky
and need some extra care, but many work out of the box.

Here is what I more or less implemented already. Especially clocking was
tricky, don't remember if it really worked in the end:

,----
| 39 matches for "^[[:space:]]*(def[maus][^eltu][a-z]*\*? " in buffer: outshine.el
|      30:(defun outshine-deadline (&optional arg)
|      40:(defun outshine-export-dispatch (&optional arg)
|      59:(defun outshine-insert-link ()
|      67:(defun outshine-open-at-point (&optional whole-buffer-p arg reference-buffer)
|      84:(defun outshine-set-tags-command ()
|      97:(defun outshine-schedule (&optional arg)
|     108:(defun outshine-todo (&optional arg)
|     148:(defun outshine-time-stamp-inactive (&optional arg)
|     213:(defun outshine-priority ()
|     228:(defun outshine-time-stamp (&optional arg)
|     254:(defun outshine-toggle-fixed-width ()
|     260:(defun outshine-toggle-comment ()
|     304:(defun outshine-sort-entries (&optional arg)
|     366:(defun outshine-previous-block ()
|     373:(defun outshine-next-block ()
|     379:(defun outshine-insert-last-stored-link ()
|     571:(defun outshine-toggle-checkbox (&optional arg)
|     596:(defun outshine-clock-in ()
|     606:(defun outshine-clock-goto ()
|     625:(defun outshine-next-link ()
|     632:(defun outshine-clock-out ()
|     644:(defun outshine-previous-link ()
|     651:(defun outshine-clock-cancel ()
|     662:(defun outshine-clock-report (&optional arg)
|     732:(defun outshine-timer-pause-or-continue (&optional arg)
|     738:(defun outshine-timer-item ()
|     744:(defun outshine-timer ()
|     750:(defun outshine-timer-start ()
|     756:(defun outshine-timer-cancel-timer ()
|     762:(defun outshine-timer-set-timer ()
|     768:(defun outshine-agenda-set-restriction-lock (&optional arg)
|     780:(defun outshine-agenda-remove-restriction-lock (&optional include-org-p)
|     797:(defun outshine-inc-effort ()
|     818:(defun outshine-set-property-and-value ()
|     847:(defun outshine-toggle-archive-tag ()
|     865:(defun outshine-insert-drawer ()
|     871:(defun outshine-set-effort (&optional arg)
|     878:(defun outshine-footnote-action (&optional special)
|     906:(defun outshine-set-property ()
`----

There are much more outcommented function skeletons waiting for (your?)
implementation in section

,----
| ;;; Use Outorg for calling Org
`----

of outshine.el. Here are a few implementation examples to show how
easy this is:

,----
| ;; C-c C-x d	org-insert-drawer
| (defun outshine-insert-drawer ()
|   "Call outorg to trigger `org-insert-drawer'."
|   (interactive)
|   (outshine-use-outorg 'org-insert-drawer))
| 
| ;; C-c C-x e	org-set-effort
| (defun outshine-set-effort (&optional arg)
|   "Call outorg to trigger `org-set-effort'."
|   (interactive "p")
|   (outshine-use-outorg
|    'org-set-effort nil arg))
| 
| ;; C-c C-x f	org-footnote-action
| (defun outshine-footnote-action (&optional special)
|   "Call outorg to trigger `org-footnote-action'."
|   (interactive "P")
|   (outshine-use-outorg
|    'org-footnote-action 'WHOLE-BUFFER-P special))
| 
| ;; C-c C-x p	org-set-property
| (defun outshine-set-property ()
|   "Call outorg to trigger `org-set-property'."
|   (interactive)
|   (outshine-use-outorg 'org-set-property))
`----

With these commands, you can call Org-mode functionality directly in
comment sections of programming modes like emacs-lisp-mode, e.g. add
TODOs, TAGS, Properties, timestamps, (maybe) even clock-in and out. 

Here I added, as an example, some Org-mode headline stuff to org.el,
directly in the elisp buffer (with outline-minor-mode and outshine
activated):

,----
| ;;; TODO [#C] Commentary: :urgent:
| ;;   :PROPERTIES:
| ;;   :CATEGORY: office
| ;;   :END:
| 
| ;; Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
| ;; project planning with a fast and effective plain-text system.
`----

-- 
cheers,
Thorsten

  parent reply	other threads:[~2015-12-01 20:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-08 15:02 Using orgstruct-mode (or just org-cycle) in emacs-lisp-mode Jonas Bernoulli
2015-11-08 15:24 ` Nicolas Goaziou
2015-11-08 15:48   ` Jonas Bernoulli
2015-11-08 17:34     ` Aaron Ecay
2015-11-09 23:40       ` Jonas Bernoulli
2015-11-10 10:54         ` Rasmus
2015-12-01 20:06         ` Thorsten Jolitz [this message]
2015-11-08 17:36     ` Jorge A. Alfaro-Murillo
2015-11-09 23:30       ` Jonas Bernoulli
2015-11-14  8:37     ` Nicolas Goaziou
2015-11-18  9:57       ` Jonas Bernoulli
2015-11-19  8:39         ` Nicolas Goaziou
2015-11-19 19:50           ` Jonas Bernoulli
2015-11-19 21:47             ` Rasmus

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=87vb8i0w9c.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).