all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: emacs-orgmode@gnu.org
Subject: Re: Clocking in on non-org files
Date: Sat, 16 Aug 2014 16:37:27 +0200	[thread overview]
Message-ID: <20140816163727.06c6dc1b@aga-netbook> (raw)
In-Reply-To: <20140816154758.7ec02caa@aga-netbook>

Dnia 2014-08-16, o godz. 15:47:58
Marcin Borkowski <mbork@wmi.amu.edu.pl> napisał(a):

> OK, sorry for spamming the list, but here's what I established (with
> the help of Edebug).  The problem is with org-heading-components; for
> some reason, the variable org-complex-heading-regexp is nil when
> running that function.  This variable is buffer-local, and it seems
> that (somehow) the value org-clock-in sees is nil.  A further
> inspection shows that the (current-buffer) is (at that time) *not* the
> one jumped to by org-open-at-point-global.  Anyone knows why that is
> so?

Got it.  Here's an excerpt from the Elisp manual:

"When an editing command returns to the editor command loop, Emacs
automatically calls `set-buffer' on the buffer shown in the selected
window."

In other words, I guess that org-open-at-point-global (and I assume
that also org-open-link-from-string) change the /selected window/ and
rely on Emacs command loop to make the respective buffer /the current
buffer/ after they exit.

Is this a good behavior?  I guess not - it makes using them
non-interactively harder.  (I was only able to find that bug because
of a recent, unrelated thread - also started by me;) - on the Emacs
mailing list!)  So let me file a feature request for such functions to
actually set the current buffer.

And here's the corrected code, which seems to work:

(defun org-clock-in-anywhere (&optional select)
  "Clock in.  If called without prefix and not in Org-mode, clock
in the entry pointed by org-default-link."
  (interactive "P")
  (if (or select (equal major-mode 'org-mode))
      (org-clock-in select)
    (save-window-excursion
      (save-selected-window
	(org-goto-default-link)
	(set-buffer (window-buffer (selected-window)))
	(org-clock-in)))))

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

  reply	other threads:[~2014-08-16 14:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-06 12:07 Clocking in on non-org files Marcin Borkowski
2013-10-06 15:11 ` Suvayu Ali
2013-10-06 21:26   ` Marcin Borkowski
2014-08-16 12:12     ` Marcin Borkowski
2014-08-16 12:31       ` Marcin Borkowski
2014-08-16 13:47         ` Marcin Borkowski
2014-08-16 14:37           ` Marcin Borkowski [this message]
2014-08-16 14:01       ` Thorsten Jolitz
2014-08-16 14:42         ` Marcin Borkowski
2014-08-16 15:02           ` Thorsten Jolitz
2014-08-16 15:13             ` Marcin Borkowski
2014-08-16 15:35               ` Thorsten Jolitz
  -- strict thread matches above, loose matches on Subject: below --
2013-10-06  7:56 Marcin Borkowski
2013-11-05 17:16 ` Bastien

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

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

  git send-email \
    --in-reply-to=20140816163727.06c6dc1b@aga-netbook \
    --to=mbork@wmi.amu.edu.pl \
    --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 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.