Re: [O] Cut and paste an entry programmatically

2019-06-28 Thread Kyle Meyer
Michael Brand  writes:

[...]

> With your idea I debug printed kill-ring and found that after the
> second invocation of org-cut-subtree during ~M-: (temp) RET M-: (temp)
> RET~ it consists of only one list element with a string containing
> both 1 and 2 instead of one list element with only 1 and another with
> only 2. So to me this looks like a bug in org-cut-subtree.

Hmm I don't consider that a bug.  It's documented behavior for kill
commands to append to the last kill when called successively.

,[ C-h f kill-region RET ]
| [...]
| Any command that calls this function is a "kill command".
| If the previous command was also a kill command,
| the text killed this time appends to the text killed last time
| to make one entry in the kill ring.
| [...]
`

To get a better feel for what's happening, I'd suggest evaluating
kill-region with C-u C-M-x and stepping through its execution.

In addition to what Samuel posted, another way for a lisp caller to
avoid the append behavior if desired is to let-bind this-command so that
kill-region's attempt to set it to kill-region doesn't work.  Using your
example, that'd be

#+begin_src emacs-lisp
(defun temp ()
  (let (this-command)
(org-cut-subtree))
  (org-forward-heading-same-level 2)
  (org-paste-subtree))
#+end_src

-- 
Kyle



Re: [O] Equivalent of timeline?

2019-06-28 Thread Samuel Wales
i was going to code the following, and documented it first,
but cannot code it.  maybe it
will be of smoe use in thinking about the problem.

i would use text search view, as follows.

i think it should be pretty small.

===

i think timeline (L) was retired from org because it
code-rotted as org developed new features, and it only
supported one file, which goes against org's sylvan (forest)
philosophy.

it occurred to me that text search could replace the
timeline agenda view.  the search is for limiting.  it is not to
search for timestamps.  yet the whole thing shows every timestamp.

===

it would cover most features.  it would not be limited to
one file unless you restrict the agenda.  it would be
relatively fast.  and you can limit by searching.

however, it would not provide the shifted (left/right) arrow
feature to change timestamps.

===

the thing is to show MULTIPLE timestamps as multiple lines
in text search view.

each has a text property that contains the timestamp that
generated it.  then we show the timestamps in the agenda
prefix.

text search view will show multiple timestamps per entry as
one entry, which is not what we want.

so we have to work around that.

===

there is a variable that is pretty late in the agenda view.
it is intended for things like removing entries or modifying
entries before displaying.  it can be used for sorting
purposes and so on.

but i suspect we can add entries.

this would be the key insight.

===

org-agenda-skip-additional-timestamps-same-entry seems to be
only for the timestamp agenda, which we would not use.

===

you can make it cover planning (c, d, s), active/event,
inactive, clocking, notes, and state changes timestamps.

(provided that you have set a variable to show inactive
timestamps -- this works but is a defvar -- and have log
mode enabled.)

however, it would not automatically generate instances of
repeaters that are not already existing.  it also would not
automatically generate internal dates within ranges (i don't
know if it would catch the endpoints, as that depends on org
internals.)

those don't seem critical for a first pass.  perhaps org
support could make it do those if it is really needed.

===

basically it looks like this as a custom command.

(";" "text search -- sorted by time" search "" ( ;; can put
 date in a longer org-agenda-prefix-format ;; sort on the
 org-supported text property timestamp ;;
 (org-agenda-cmp-user-defined #'alpha-org-agenda-cmp--time)
 (org-agenda-sorting-strategy '(user-defined-up

if you want to filter by a text search, you enter that; if
not, you enter . (or maybe nothing) to show all.

filtering allows you to answer questions like "when were all
the times i mentioned "org-mode?"  "which was the first time
i mentioned 'org-mode' that is significant?"  which seems
more useful than a huge slow list of every timestamp in your
agenda and agenda text search extra files.

===

fwiw



Re: [O] Links to LaTeX equations

2019-06-28 Thread John Kitchin
Org-ref provides a ref link for exactly this purpose. It looks like
ref:an-equation and if you click on it it jumps to the label. The link is
red if the label doesn't exist and maroonish if it does. It exports in
latex as \ref{an-equation}. It sounds like just what you need.

You can get org-ref on melpa.

On Fri, Jun 28, 2019 at 9:15 AM Fraga, Eric  wrote:

> Hello all,
>
> it's that time of year where I have to think about revamping my lecture
> slides (having just finished one year, the next one starts...).  I write
> these in org and export to beamer obviously!
>
> I teach a technical subject.  I therefore have quite a few equations in
> my slides and I use LaTeX for these.  I would like to be able to use org
> fully with respect to links and targets.  If I define a label in LaTeX
> directly, \label{an-equation} for instance, I get no benefit from using
> an org link to it, e.g. [[an-equation]] (by default, this leads to the
> org exporter complaining about a missing target and if I tell org not to
> complain I subsequently miss real errors).  So I use inline LaTeX to
> provide the link, as in \ref{an-equation}.  But then I lose the ability
> to jump to the target within org, something which is quite useful given
> that I have many slides for the full module I teach.
>
> The only satisfactory solution I have found is to do something along
> these lines:
>
> #+begin_src org
>   The equation is:
>   ,#+begin_equation
>   <>
>   y = x + 3
>   ,#+end_equation
>
>   (later) In equation [[an-equation]], we see nothing much.
> #+end_src
>
> This works in that I can jump to the label by clicking on the link but I
> lose the ability to edit the equation in LaTeX mode.
>
> Any pointers would be welcome.
>
> Thanks,
> eric
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.2.4-379-g1b74ae
>
-- 
John

---
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


Re: [O] Links to LaTeX equations

2019-06-28 Thread Fraga, Eric
On Friday, 28 Jun 2019 at 10:19, John Kitchin wrote:
> Org-ref provides a ref link for exactly this purpose. 

Thanks John.  I've looked at org-ref before and it looks nice.  However,
due to my organically grown org (and Emacs) customizations (over 35
years...), I couldn't get it to work well for me.  Yes, I must clean up
my .emacs some day!

Using #+name: does the job for the moment.

Thanks again,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.4-379-g1b74ae


Re: [O] Links to LaTeX equations

2019-06-28 Thread Ken Mankoff
Hi Eric,

On 2019-06-28 at 10:55 -02, Fraga, Eric  wrote...
> I would like to be able to use org fully with respect to links and
> targets. If I define a label in LaTeX directly, \label{an-equation}
> for instance, I get no benefit from using an org link to it, e.g.
> [[an-equation]]

Why don't you define the link in Org?

#+NAME: eq:foo
\begin{equation}
foo
\end{equation}

  -k.



Re: [O] Links to LaTeX equations

2019-06-28 Thread Fraga, Eric
On Friday, 28 Jun 2019 at 11:58, Ken Mankoff wrote:
> Why don't you define the link in Org?
>
> #+NAME: eq:foo
> \begin{equation}

And why are the obvious solutions not those that come to mind (for
me)

Many thanks.  Nothing in the documentation to even suggest this
possibility.  That's my excuse. :)
-- 
: Professor Eric S Fraga, http://www.homepages.ucl.ac.uk/~ucecesf
: Required hieroglyphics follow: ∀ε>0,∃δ>0∋|x-x₀|<δ⇒|f(x)-f(x₀)|<ε


[O] Equivalent of timeline?

2019-06-28 Thread James Harkins
I recently had to make a document listing my professional activities (lectures 
and performances). Items are dated.

I would like to see an overview of them, sorted by date.

In the past I would have used a Timeline agenda for this, but that's no longer 
possible.

https://www.reddit.com/r/orgmode/comments/7hps9j/rip_orgtimeline/ provides a 
custom agenda command that is supposed(?) to mimic the old timeline, but it 
didn't.

So how does one do it?

hjh




Re: [O] Cut and paste an entry programmatically

2019-06-28 Thread Michael Brand
Hi Samuel

On Thu, Jun 27, 2019 at 11:57 PM Samuel Wales  wrote:
> does (kill-new "") in front of the kill fix it?

Good idea. Yes, it prevents reinsertion of "1". Same with (setq
kill-ring nil) in front of org-cut-subtree.

With your idea I debug printed kill-ring and found that after the
second invocation of org-cut-subtree during ~M-: (temp) RET M-: (temp)
RET~ it consists of only one list element with a string containing
both 1 and 2 instead of one list element with only 1 and another with
only 2. So to me this looks like a bug in org-cut-subtree.

Michael



[O] Links to LaTeX equations

2019-06-28 Thread Fraga, Eric
Hello all,

it's that time of year where I have to think about revamping my lecture
slides (having just finished one year, the next one starts...).  I write
these in org and export to beamer obviously!

I teach a technical subject.  I therefore have quite a few equations in
my slides and I use LaTeX for these.  I would like to be able to use org
fully with respect to links and targets.  If I define a label in LaTeX
directly, \label{an-equation} for instance, I get no benefit from using
an org link to it, e.g. [[an-equation]] (by default, this leads to the
org exporter complaining about a missing target and if I tell org not to
complain I subsequently miss real errors).  So I use inline LaTeX to
provide the link, as in \ref{an-equation}.  But then I lose the ability
to jump to the target within org, something which is quite useful given
that I have many slides for the full module I teach.

The only satisfactory solution I have found is to do something along
these lines:

#+begin_src org
  The equation is:
  ,#+begin_equation
  <>
  y = x + 3
  ,#+end_equation

  (later) In equation [[an-equation]], we see nothing much.
#+end_src

This works in that I can jump to the label by clicking on the link but I
lose the ability to edit the equation in LaTeX mode.

Any pointers would be welcome.

Thanks,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.4-379-g1b74ae