[O] [PATCH] org-mac-link: Improve grabbing behavior for Chrome.

2014-03-22 Thread Muchenxuan Tong
* contrib/lisp/org-mac-link.el (org-as-mac-chrome-get-frontmost-url):
  Improve AppleScript used for grabbing information from Chrome. Now
  it's shorter and doesn't require switching to the app. Also,
  starting and ending quote are trimmed only when necessary.
---
 contrib/lisp/org-mac-link.el | 32 
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index ef46171..d1687e0 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -349,26 +349,18 @@ applications and inserting them in org documents"
 
 (defun org-as-mac-chrome-get-frontmost-url ()
   (let ((result (do-applescript
-(concat
- "set oldClipboard to the clipboard\n"
- "set frontmostApplication to path to frontmost 
application\n"
- "tell application \"Google Chrome\"\n"
- " activate\n"
- " delay 0.15\n"
- " tell application \"System Events\"\n"
- " keystroke \"l\" using command down\n"
- " keystroke \"c\" using command down\n"
- " end tell\n"
- " delay 0.15\n"
- " set theUrl to the clipboard\n"
- " set the clipboard to oldClipboard\n"
- " set theResult to (get theUrl) & \"::split::\" & (get 
name of window 1)\n"
- "end tell\n"
- "activate application (frontmostApplication as text)\n"
- "set links to {}\n"
- "copy theResult to the end of links\n"
- "return links as string\n"
-(substring (car (split-string result "[\r\n]+" t)) 1 -1)))
+(concat
+  "set frontmostApplication to path to frontmost application\n"
+  "tell application \"Google Chrome\"\n"
+  "set theUrl to get URL of active tab of first window\n"
+  "set theResult to (get theUrl) & \"::split::\" & (get 
name of window 1)\n"
+  "end tell\n"
+  "activate application (frontmostApplication as text)\n"
+  "set links to {}\n"
+  "copy theResult to the end of links\n"
+  "return links as string\n"
+(replace-regexp-in-string "^\"\\|\"$" ""
+ (car (split-string result "[\r\n]+" t)
 
 (defun org-mac-chrome-get-frontmost-url ()
   (interactive)
-- 
1.9.1




[O] [PATCH] save-restriction in `org-mobile-push'

2013-07-18 Thread Muchenxuan Tong
* lisp/org-mobile.el (org-mobile-push): add `save-restriction'

The fact that pushing org-file loses my narrow context annoys me.

TINYCHANGE
---
 lisp/org-mobile.el | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 7cdaf34..a43896b 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -319,23 +319,24 @@ create all custom agenda views, for upload to the mobile 
phone."
  (org-agenda-tag-filter org-agenda-tag-filter)
  (org-agenda-redo-command org-agenda-redo-command))
   (save-excursion
-   (save-window-excursion
- (run-hooks 'org-mobile-pre-push-hook)
- (org-mobile-check-setup)
- (org-mobile-prepare-file-lists)
- (message "Creating agendas...")
- (let ((inhibit-redisplay t)
-   (org-agenda-files (mapcar 'car org-mobile-files-alist)))
-   (org-mobile-create-sumo-agenda))
- (message "Creating agendas...done")
- (org-save-all-org-buffers) ; to save any IDs created by this process
- (message "Copying files...")
- (org-mobile-copy-agenda-files)
- (message "Writing index file...")
- (org-mobile-create-index-file)
- (message "Writing checksums...")
- (org-mobile-write-checksums)
- (run-hooks 'org-mobile-post-push-hook)))
+   (save-restriction
+ (save-window-excursion
+   (run-hooks 'org-mobile-pre-push-hook)
+   (org-mobile-check-setup)
+   (org-mobile-prepare-file-lists)
+   (message "Creating agendas...")
+   (let ((inhibit-redisplay t)
+ (org-agenda-files (mapcar 'car org-mobile-files-alist)))
+ (org-mobile-create-sumo-agenda))
+   (message "Creating agendas...done")
+   (org-save-all-org-buffers) ; to save any IDs created by this process
+   (message "Copying files...")
+   (org-mobile-copy-agenda-files)
+   (message "Writing index file...")
+   (org-mobile-create-index-file)
+   (message "Writing checksums...")
+   (org-mobile-write-checksums)
+   (run-hooks 'org-mobile-post-push-hook
   (setq org-agenda-buffer-name org-agenda-curbuf-name
org-agenda-this-buffer-name org-agenda-curbuf-name))
 (redraw-display)
-- 
1.8.3.2




Re: [O] Bug: Append new heading when :END: exists

2013-04-24 Thread Muchenxuan Tong
Cool!

Thanks!


On Wed, Apr 24, 2013 at 3:57 PM, Bastien  wrote:

> Hi Muchenxuan,
>
> Muchenxuan Tong  writes:
>
> > 1. Assume that the content is:
> > * Hello
> >   :LOGBOOK:
> >   - Note taken on [2013-04-22 Mon 16:57] \\
> > hello
> >   :END:
> >
> > 2. Fold it, so that it becomes
> > * Hello…
> >
> > 3. Put the cursor at the end of the heading, and press M-RET or C-RET
> > * Hello…(here)
> >
> > The new "*" will be in the beginning of :END:, which is incorrect.
>
> This is now fixed, along with the other problem reported by John for
>
> * heading
> #+begin_src sh
> ...
> #+end_src
>
> Thanks,
>
> --
>  Bastien
>


Re: [O] Bug: Append new heading when :END: exists

2013-04-22 Thread Muchenxuan Tong
I checked the code of `org-insert-heading'.

One potential factor: when folded, and putting cursor and the end of
heading, the cursor is supposed to be

:END: (here)

and it's not judged as a heading.


On Tue, Apr 23, 2013 at 2:57 AM, Bastien  wrote:

> I'm tempted to apply the following patch, as this problem falls under
> the category of "inserting in an invisible region".  I don't think it
> breaks any non-interactive call of org-insert-heading, but this needs
> further checking.
>
> Also, note that the problem occurs only when there is no blank line
> between the :END: and the following headline, so maybe the real fix
> has to be within org-insert-heading...
>
>
>
> --
>  Bastien
>
>


[O] Bug: Append new heading when :END: exists

2013-04-22 Thread Muchenxuan Tong
1. Assume that the content is:
* Hello
  :LOGBOOK:
  - Note taken on [2013-04-22 Mon 16:57] \\
hello
  :END:

2. Fold it, so that it becomes
* Hello…

3. Put the cursor at the end of the heading, and press M-RET or C-RET
* Hello…(here)

The new "*" will be in the beginning of :END:, which is incorrect.


[O] [PATCH] Locally scope the variable `org-agenda-tag-filter' in `org-agenda-filter-by-tag'

2013-03-20 Thread Muchenxuan Tong
* lisp/org-agenda.el: Introduce a local variable tag-filter to replace
  the global variable `org-agenda-tag-filter'.

This relates to the bug when trying to filter by tag in agenda view with
entry-text shown. In `org-agenda-filter-apply' ->
`org-agenda-entry-text-mode', it shows error when the global variable
`org-agenda-tag-filter' is set. Thus, the variable
`org-agenda-tag-filter' shouldn't be set in advance.

Modifying the global one will be done anyway in
`org-agenda-filter-apply', which happens after
calling (org-agenda-entry-text-mode).

TINYCHANGE.
---
 lisp/org-agenda.el | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index afaf009..acb8cb0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7333,6 +7333,7 @@ to switch to narrowing."
 (effort-prompt "")
 (inhibit-read-only t)
 (current org-agenda-tag-filter)
+(tag-filter org-agenda-tag-filter)
 maybe-refresh a n tag)
 (unless char
   (message
@@ -7373,24 +7374,24 @@ to switch to narrowing."
  ((equal char ?\r)
   (org-agenda-filter-show-all-tag)
   (when org-agenda-auto-exclude-function
-   (setq org-agenda-tag-filter '())
+   (setq tag-filter '())
(dolist (tag (org-agenda-get-represented-tags))
  (let ((modifier (funcall org-agenda-auto-exclude-function tag)))
(if modifier
-   (push modifier org-agenda-tag-filter
-   (if (not (null org-agenda-tag-filter))
-   (org-agenda-filter-apply org-agenda-tag-filter 'tag)))
+   (push modifier tag-filter
+   (if (not (null tag-filter))
+   (org-agenda-filter-apply tag-filter 'tag)))
   (setq maybe-refresh t))
  ((equal char ?/)
   (org-agenda-filter-show-all-tag)
-  (when (get 'org-agenda-tag-filter :preset-filter)
-   (org-agenda-filter-apply org-agenda-tag-filter 'tag))
+  (when (get 'tag-filter :preset-filter)
+   (org-agenda-filter-apply tag-filter 'tag))
   (setq maybe-refresh t))
  ((equal char ?. )
-  (setq org-agenda-tag-filter
+  (setq tag-filter
(mapcar (lambda(tag) (concat "+" tag))
(org-get-at-bol 'tags)))
-  (org-agenda-filter-apply org-agenda-tag-filter 'tag)
+  (org-agenda-filter-apply tag-filter 'tag)
   (setq maybe-refresh t))
  ((or (equal char ?\ )
  (setq a (rassoc char alist))
@@ -7404,10 +7405,10 @@ to switch to narrowing."
  (and tag (setq a (cons tag nil
   (org-agenda-filter-show-all-tag)
   (setq tag (car a))
-  (setq org-agenda-tag-filter
+  (setq tag-filter
(cons (concat (if strip "-" "+") tag)
  (if narrow current nil)))
-  (org-agenda-filter-apply org-agenda-tag-filter 'tag)
+  (org-agenda-filter-apply tag-filter 'tag)
   (setq maybe-refresh t))
  (t (error "Invalid tag selection character %c" char)))
 (when (and maybe-refresh
-- 
1.7.12.4 (Apple Git-37)




Re: [O] Feature: Group and limit items in agenda

2013-02-16 Thread Muchenxuan Tong
Yes I understand your point. However, setting TODO for each category
manually would be laborious in my situation, I have to adjust the
configuration file each time I add/delete the project.

For my implementation, I advice on function 'org-agenda-finalize-entries'
to put lists into different groups, limit them and add separator after the
line '(setq list (mapcar 'org-agenda-highlight-todo list))'

There's a 'org-agenda-before-sorting-filter-function' variable. However,
I'm not able to use it for grouping things, because it's used as '(mapcar
org-agenda-before-sorting-filter-function list)'

Would it be useful to add another function here, not used in 'mapcar', but
work directly on the whole list? I don't know whether it is worthy, and I'm
OK if that's not general enough to be added, because I can use defadvice
anyway :)


On Mon, Feb 11, 2013 at 9:42 PM, Bastien  wrote:

> Hi Muchenxuan,
>
> Muchenxuan Tong  writes:
>
> > My intention is to limit the number of tasks in each category.
>
> Did you check (info "(org)Block Agenda") ?
>
> That's the way I would suggest: define a block agenda listing
> the various categories, then use `org-agenda-max-todos' in each
> of them to limit the number of TODOs.
>
> > For the new proposed 'org-agenda-max-todos', I can only limit the
> > number of TODOs in the whole TODO lists.
> >
> > Maybe for what I want, it's desirable to add a auto-split or
> > auto-group features, where a list of TODOs, can be split further into
> > multiple lists of TODOs, by a certain criteria (tags, category).
> >
> > What do you think about it?
>
> I understand defining block agendas is not as straightforward than the
> solution you envision, but my feeling is that allowing grouping+limits
> will have too much overlap with the block agenda functionality.
>
> Let me know if you find the path to happiness with a combinaison of
> block agendas and the new variables.
>
> Thanks,
>
> --
>  Bastien
>


Re: [O] Feature: Group and limit items in agenda

2013-02-10 Thread Muchenxuan Tong
Thanks for the new feature. I tried and it works well for what it intended
to do. However, I still haven't found a way to do the kind of things I
mentioned.

My intention is to limit the number of tasks in each category. For the new
proposed 'org-agenda-max-todos', I can only limit the number of TODOs in
the whole TODO lists.

Maybe for what I want, it's desirable to add a auto-split or auto-group
features, where a list of TODOs, can be split further into multiple lists
of TODOs, by a certain criteria (tags, category).

What do you think about it?


On Thu, Feb 7, 2013 at 6:41 PM, Bastien  wrote:

> Hi Muchenxuan,
>
> Muchenxuan Tong  writes:
>
> > * Motivation
> > - Sacha Chua proposed a solution for viewing top three tasks by
> > context (
> http://sachachua.com/blog/2012/12/emacs-org-display-subset-tasks-context/)
> > - In the Next view in Things (http://culturedcode.com/), one is able
> > to setting to see only a limited numbers of top tasks of each
> > project.
>
> Thanks for the pointers.  From latest Org (master branch), you
> can now use `org-agenda-max-entries' either as a global option,
> or locally in each agenda view.
>
> See the docstring on how to use this option and its friends:
>
>   org-agenda-max-effort
>   org-agenda-max-tags
>   org-agenda-max-todos
>
> org-agenda-max-effort might be particularily useful in TODO views.
>
> Let me know if this works for you.
>
> As for "grouping", I think this is more about setting agenda views,
> sorting options and agenda filters properly -- but I'm open to any
> idea on how to improve this (or to make it easier to set.)
>
> Thanks!
>
> --
>  Bastien
>


Re: [O] [PATCH] Bug fix: delete indirect buffer's window only when it exists.

2013-01-22 Thread Muchenxuan Tong
Ok. Thanks.

On 22 Jan 2013, at 21:25, Bastien wrote:

> Hi Muchenxuan,
>
> Muchenxuan Tong  writes:
>
>> Thanks for pointing out. It's my fault, when-let is defined in slime.el
>> and not the Emacs core library.
>>
>> The following patch should be OK:
>
> I've applied the patch.  Please do not insert patches in the body of
> the message, attach them.  Also, you can use git format-patch to send
> them, it's easier for me to apply.
>
> Thanks,
>
> --
> Bastien



Re: [O] [PATCH] Bug fix: delete indirect buffer's window only when it exists.

2013-01-21 Thread Muchenxuan Tong
Achim Gratz  nexgo.de> writes:

> 
> Muchenxuan Tong writes:
> > Bug fix: delete indirect buffer's window only when it exists.
> > * org-agenda.el (org-agenda-quit): Delete indirect buffer's window
> > only when it exists.
> 
> Introduces a new bug: when-let is not defined in GNU Emacs.
> 
> Regards,
> Achim.

Thanks for pointing out. It's my fault, when-let is defined in slime.el 
and not the Emacs core library.

The following patch should be OK:

Bug fix: delete indirect buffer's window only when it exists.
* org-agenda.el (org-agenda-quit): Delete indirect buffer's window
only when it exists.

When indirect buffer's window doesn't exist, the original logic will
delete the current window.

TINYCHANGE

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f48ff6f..8b9ae81 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6989,7 +6989,10 @@ When `org-agenda-sticky' is non-nil, only bury
the agenda."
   (interactive)
   (if (and (eq org-indirect-buffer-display 'other-window)
   org-last-indirect-buffer)
-  (delete-window (get-buffer-window org-last-indirect-buffer)))
+  (let ((org-last-indirect-window
+(get-buffer-window org-last-indirect-buffer)))
+   (if org-last-indirect-window
+   (delete-window org-last-indirect-window
   (if org-agenda-columns-active
   (org-columns-quit)
 (if org-agenda-sticky




[O] [PATCH] Bug fix: delete indirect buffer's window only when it exists.

2013-01-21 Thread Muchenxuan Tong
Bug fix: delete indirect buffer's window only when it exists.
* org-agenda.el (org-agenda-quit): Delete indirect buffer's window
only when it exists.

When indirect buffer's window doesn't exist, the original logic will
delete the current window.

TINYCHANGE

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f48ff6f..530e79a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6989,7 +6989,9 @@ When `org-agenda-sticky' is non-nil, only bury
the agenda."
   (interactive)
   (if (and (eq org-indirect-buffer-display 'other-window)
org-last-indirect-buffer)
-  (delete-window (get-buffer-window org-last-indirect-buffer)))
+  (when-let (org-last-indirect-window
+ (get-buffer-window org-last-indirect-buffer))
+ (delete-window org-last-indirect-window)))
   (if org-agenda-columns-active
   (org-columns-quit)
 (if org-agenda-sticky



[O] Feature suggestion: VISIBILITY: n children

2013-01-03 Thread Muchenxuan Tong
Right now for 'VISIBILITY' property Org has the following options: 
folded, children, content, all


I think one more flexible options--n children--would be useful (n is a 
integer)


It restricts how many top children you can see under the current headline.

This is inspired by Things for Mac app, where in the "Next" view, for 
each project, you only see the 3 immediate todos. I want the same thing 
in my Org work flow but found no straightforward solution.




[O] [PATCH] Check org-timer-display in org-timer-set-mode-line when, value is 'off

2012-08-28 Thread Muchenxuan Tong

Check org-timer-display in org-timer-set-mode-line when value is 'off

* lisp/org-timer.el (org-timer-set-mode-line): Check org-timer-display when
  value is 'off.

This solves the error of (org-timer-set-mode-line 'off) when 
org-timer-display

is 'mode-line. In this case frame-title-format may not be a list.

TINYCHANGE
---
 lisp/org-timer.el | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 551dbea..92aaf1c 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -304,10 +304,14 @@ VALUE can be `on', `off', or `pause'."
 (when org-timer-mode-line-timer
   (cancel-timer org-timer-mode-line-timer)
   (setq org-timer-mode-line-timer nil))
-(setq global-mode-string
-  (delq 'org-timer-mode-line-string global-mode-string))
-(setq frame-title-format
-  (delq 'org-timer-mode-line-string frame-title-format))
+(when (or (eq org-timer-display 'mode-line)
+  (eq org-timer-display 'both))
+  (setq global-mode-string
+(delq 'org-timer-mode-line-string global-mode-string)))
+(when (or (eq org-timer-display 'frame-title)
+  (eq org-timer-display 'both))
+  (setq frame-title-format
+(delq 'org-timer-mode-line-string frame-title-format)))
 (force-mode-line-update))
((equal value 'pause)
 (when org-timer-mode-line-timer
--
1.7.12




[O] License issue for a clone in a commercial editor

2012-06-28 Thread Muchenxuan Tong
Hi.

I just started a clone of some features of Org mode to the markdown mode of a 
commercial editor (Sublime Text 2); it's available at 
https://github.com/demon386/SmartMarkdown

It's based on Python and until now I haven't referred to the implementation of 
Org. However, plan-text table is very challenging and I'm prepared to refer to 
the implementation of Org.

I'm not very clear about the license issue in this case. Currently the plugin 
is licensed under MIT license. Is it necessary for me to release the plugin 
under GPL?

Thanks.

[O] Bug: Falsely identify Table formula as INVISIBLE target

2012-03-14 Thread Muchenxuan Tong
I use a formula like this in my org table:

#+TBLFM: $>=vmean($<<..$>>);%.3f

However, when I export the org table to a latex file, there appears a line
in the tex file like this:

<<..\$>>(INVISIBLE)

If I use  #+TBLFM: $>=vmean($2..$>>);%.3f, the problem will disappear. I
think this is caused by the functions in org-exp.el falsely identifies the
formula as INVISIBLE target.

By: Muchenxuan Tong


[O] Bug: CLOCK_MODELINE_TOTAL and org-todo-yesterday

2012-02-17 Thread Muchenxuan Tong
1. Sometimes I want all the subtrees of a tree to inheritance the
property "CLOCK_MODELINE_TOTAL" (e.g. all set to "today"), but in the
function *org-clock-get-sum-start*, you use (org-entry-get nil
"CLOCK_MODELINE_TOTAL"), which means that it doesn't search inheritance.
This makes the inheritance setting in vain.

2. Sometimes I want to mark something done yesterday (e.g. I'm leaving
that night but still finishing the project without computer at hand). I use
*org-todo-yesterday*, but I find that if it has a *++ repeater*, the new
date begins *as if the task is done today*, which is not desirable.

By: Muchenxuan Tong