[Orgmode] Let tab do org-cycle only at special place.

2007-05-23 Thread levin
I've my busy tab key set to a super expand/indent function:

   (global-set-key "\t" 'ext-super-tab)

Currently in org-mode, tab is only doing indent in none headline/special 
place. I'd like to use tab only at the beginning of headline or buffer. So I 
put something like this in my org-conf.el :

(defun org-tab (&optional arg)
  "Do org-cycle only at the beginning of a headline, otherwise do
the job defined in global keymap."
  (interactive "P")
  (let* ((outline-regexp
  (if (and (org-mode-p) org-cycle-include-plain-lists)
  "\\(?:\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)"
outline-regexp))
 (bob-special (and org-cycle-global-at-bob (bobp)
   (not (looking-at outline-regexp)
(if (or bob-special
(eq arg t)
(integerp arg)
(org-at-table-p 'any)
(looking-at outline-regexp))
(org-cycle arg)
  (call-interactively (global-key-binding "\t")

(define-key org-mode-map [(tab)] 'org-tab)

Hope this is useful for someone else.

Levin


___
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] [PATCH]add a custom function to get date string in agenda

2007-09-11 Thread Levin
I have a special need of customizing date string in agenda (the date format 
string is even not enough because I'd like other date format than Gregorian). 
So I add a custom variable org-agenda-date-string-function,
bind it to org-agenda-date-string to preserve current org behaviour.

Then in my org conf file, I add:
(defun my-org-agenda-date-string (date)
  (...))

(setq org-agenda-date-string-function 'my-org-agenda-date-string)

Hope it helps.
--
Levin

diff --git a/lisp/org/org.el b/lisp/org/org.el
index 97bde49..3f6c9b5 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -2322,6 +2322,15 @@ FIXME: Not used currently, because of timezone 
problem."
   :group 'org-agenda-daily/weekly
   :type 'string)
 
+(defcustom org-agenda-date-string-function
+  'org-agenda-date-string
+  "Function that obtains a string for displaying date in the agenda.
+Used by the daily/weekly agenda and by the timeline.
+
+This function is passed a date and should return a string."
+  :group 'org-agenda-daily/weekly
+  :type 'function)
+
 (defcustom org-agenda-include-diary nil
   "If non-nil, include in the agenda entries from the Emacs Calendar's 
diary."
   :group 'org-agenda-daily/weekly
@@ -17565,6 +17574,12 @@ When a buffer is unmodified, it is just killed.  When 
modified, it is saved
   (or (cdar tbl) (cdr (nth (1- (length org-category-table))
   org-category-table))
 ;;; Agenda timeline
+(defun org-agenda-date-string (date)
+  (format "%-9s %2d %s %4d\n" 
+  (calendar-day-name date)
+  (extract-calendar-day date)
+  (calendar-month-name (extract-calendar-month date))
+  (extract-calendar-year date)))
 
 (defun org-timeline (&optional include-all)
   "Show a time-sorted view of the entries in the current org file.
@@ -17626,10 +17641,8 @@ dates."
  entry date args)))
(if (or rtn (equal d today) org-timeline-show-empty-dates)
(progn
- (insert (calendar-day-name date) " "
- (number-to-string (extract-calendar-day date)) " "
- (calendar-month-name (extract-calendar-month date)) " "
- (number-to-string (extract-calendar-year date)) "\n")
+  (insert (funcall org-agenda-date-string-function date)
+  "\n")
 ; FIXME: this gives a timezone problem
 ;(insert (format-time-string org-agenda-date-format
 ;(calendar-time-from-absolute d 0))
@@ -17806,11 +17819,8 @@ NDAYS defaults to `org-agenda-ndays'."
(setq rtnall (append rtnall rtn
   (if (or rtnall org-agenda-show-all-dates)
  (progn
-   (insert (format "%-9s %2d %s %4d\n"
-   (calendar-day-name date)
-   (extract-calendar-day date)
-   (calendar-month-name (extract-calendar-month date))
-   (extract-calendar-year date)))
+   (insert (funcall org-agenda-date-string-function date)
+"\n")
 ; FIXME: this gives a timezone problem
 ;  (insert (format-time-string org-agenda-date-format
 ;  (calendar-time-from-absolute d 0)) "\n")


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] [PATCH]add a custom function to get date string in agenda

2007-09-12 Thread Levin
Carsten Dominik wrote:
> Hi Levin,
>
> I always wanted this to be configurable, but used to have a strange
> time zone problem with this.  Your patch made me look again, and I
> think I now understand what the problem was, and it is fixed now.
>
> So I am implementing a slightly different version of you patch.
> The new variable org-agenda-format-date can be a format string for
> format-time-string, or it can be a function just like you describe it.
> This will be in 5.09.
>
> Thanks!
>
> - Carsten

That's great!

- Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Release: Org-mode 5.09

2007-09-18 Thread Levin
Hi Carsten,

>- Priority cycling goes back to the nil state.

Priority cycling is a bit odd. When I use M-n to cycle, it turns 
from #C-> nil-> #C-> nil, and M-p will be #A->nil->#A->nil.

So I write this small patch to achieve: M-n will cycle from 
#A->#B->#C->nil->#A, and M-p will cycle from #C->#B->#A->nil->#C.

Hope it helps.

-Levin

;; This patch is against org 5.09

diff --git a/lisp/org/org.el b/lisp/org/org.el
index f4746b4..a5567f5 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -13462,7 +13462,11 @@ ACTION can be `set', `up', `down', or a character."
   (if (looking-at org-priority-regexp)
  (setq current (string-to-char (match-string 2))
have t)
-   (setq current org-default-priority))
+   (setq current (if (eq action 'up)
+ (1+ org-lowest-priority)
+   (if (eq action 'down)
+   (1- org-highest-priority)
+ org-default-priority
   (cond
((or (eq action 'set) (integerp action))
(if (integerp action)


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Release: Org-mode 5.09

2007-09-18 Thread Levin
There's a small bug with org-fast-todo-selection, pressing " " will trigger an 
error instead of clearing the todo state.

Is this small fix ok?

-Levin

diff --git a/lisp/org/org.el b/lisp/org/org.el
index a5567f5..edb5cb2 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -13058,7 +13058,7 @@ Returns the new TODO keyword, or nil if no state 
change should occur."
((or (= c ?\C-g)
(and (= c ?q) (not (rassoc c fulltable
(setq quit-flag t))
-   ((= c ?\ ) 'none)
+   ((= c ?\ ) nil)
((setq e (rassoc c fulltable) tg (car e))
tg)
(t (setq quit-flag t))


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Thanks

2007-09-18 Thread Levin
> On 2007-09-18 09:15 +0100, Carsten Dominik wrote:
> > Thanks!
> >
> > - Carsten
>
> And thank you, Carsten, for making org!

Yes, org is of great help. Thank you very much, Carsten!

- Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Release: Org-mode 5.09

2007-09-18 Thread Levin
Another thing, if no todo state speedkey is specified, C-u C-c C-t will not 
function correctly.

Test file:
--8<8<
#+SEQ_TODO: TODO STARTED WAITING DELEGATED APPT | DONE DEFERRED CANCELLED

* task1
* task2
--8<8<----


-Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] possible bug of display time-range appt in agenda

2007-09-23 Thread Levin
Put something in the org buffer:
** Do something <2007-10-01 11:30-12:20>

then in the agenda, only "Do something" is displayed, without showing the appt 
time.

I trace the code and find out that: 
 (org-get-time-of-day "<2007-10-01 11:30-12:20>")
which return nil cause this probem.

I do not know if this bug has been mentioned or resolved. I'm posting here in 
case that it is not :)

-Levin

PS. I did a patch, which solves the problem. Yet it is a bit ugly :)

(It is the diff of org-get-time-of-day function. line number may be wrong.)
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -19113,9 +19113,9 @@ HH:MM."
 (when
  (or
   (string-match
-   "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s)
+   "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)? *" s)
   (string-match
-   "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\> *" 
s))
+   "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\) *" s))
  (let* ((h (string-to-number (match-string 1 s)))
(m (if (match-end 3) (string-to-number (match-string 3 s)) 0))
(ampm (if (match-end 4) (downcase (match-string 4 s



___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] org-toc.el - browsable table of contents for Org

2007-09-24 Thread Levin
> Hi folks,
>
> here is a new package for Org. It lets you browse the table of contents
> of any Org buffer:
>
>   http://www.cognition.ens.fr/~guerry/u/org-toc.el
>
> What it basically does is to create an indirect buffer from your Org
> buffer, set it to read-only, then lets you navigate through it.
>

This is very useful. It'll be another org killer tool.
I'd like to make some suggestions:
1. Preserve the org buffer tree state when entering org-toc. Currently they 
are all collapsed.

2. pressing tab in org-toc will not only cyle in org buffer, but also in the 
org-toc buffer (of course, only headlines are shown).

3. it's very useful for org-toc to keep its state, so next time it is called, 
the toc structure is shown and unchanged. (maybe one org-toc per org buffer, 
and pressing `g' in org-toc to refresh?)

-Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Feature Request: Number format on sum of property

2007-10-24 Thread Levin
Currently I'm using org-mode to manage my financial tables. The columnview is 
absolutely great on this:

8<--8<
* org-balance
   :PROPERTIES:
:COLUMNS: %30ITEM %20balance(Book Balance){+} %20uncleared(Uncleared)
{+} %20bank(Bank Balance){+}
   :END:

#+BEGIN: columnview :hlines 1 :id local
| ITEM|   Book Balance | Uncleared |   Bank Balance |
|-++---+|
| *  org-balance  | 244.850002 |   0.0 | 244.850002 |
| **  housing | -150.0 |   0.0 | -150.0 |
| ***  Parking|-150.00 |  0.00 |-150.00 |
| **  communication   | 394.85 |   0.0 | 394.85 |
| ***  wang tong  | 160.00 |  0.00 | 160.00 |
| ***  xiao ling tone | 103.00 |  0.00 | 103.00 |
| ***  shen zhou xing | 131.85 |  0.00 | 131.85 |
#+END
8<--8<

However, you might notice that the float number is not correctly formatted.
May I have some magic cookie in COLUMNS format to specify it? Something like
 "%20balance(Book Balance){+}[%.2f]" ?

Thanks.

Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] org-olpath-completing-read is not friendly with partial-completion-mode

2009-10-15 Thread Levin Du
Try this:

(partial-completion-mode t)
(funcall 'org-olpath-completing-read "? "
 '("todo1.org/tasks/"
  "todo1.org/tasks/normal/"
  "todo1.org/tasks/urgent/"
  "note.org/")
 nil t nil nil)

todo

It stays on todo1.org/ (Sole completion)



my raw patch:
diff --git a/vendor/org/org.el b/vendor/org/org.el
index d3d886f..f3a02cf 100644
--- a/vendor/org/org.el
+++ b/vendor/org/org.el
@@ -7780,23 +7780,29 @@ from."

 (defun org-icompleting-read (&rest args)
   "Completing-read using `ido-mode' or `iswitchb' speedups if available"
-  (if (and org-completion-use-ido
-  (fboundp 'ido-completing-read)
-  (boundp 'ido-mode) ido-mode
-  (listp (second args)))
-  (let ((ido-enter-matching-directory nil))
-   (apply 'ido-completing-read (concat (car args))
-  (if (consp (car (nth 1 args)))
-  (mapcar (lambda (x) (car x)) (nth 1 args))
-(nth 1 args))
-  (cddr args)))
-(if (and org-completion-use-iswitchb
-(boundp 'iswitchb-mode) iswitchb-mode
-(listp (second args)))
-   (apply 'org-iswitchb-completing-read (concat (car args))
-  (mapcar (lambda (x) (car x)) (nth 1 args))
-  (cddr args))
-  (apply 'completing-read args
+  (let ((saved-pc-mode partial-completion-mode))
+(when saved-pc-mode
+  (partial-completion-mode 0))
+(unwind-protect
+(if (and org-completion-use-ido
+ (fboundp 'ido-completing-read)
+ (boundp 'ido-mode) ido-mode
+ (listp (second args)))
+(let ((ido-enter-matching-directory nil))
+  (apply 'ido-completing-read (concat (car args))
+ (if (consp (car (nth 1 args)))
+ (mapcar (lambda (x) (car x)) (nth 1 args))
+   (nth 1 args))
+ (cddr args)))
+  (if (and org-completion-use-iswitchb
+   (boundp 'iswitchb-mode) iswitchb-mode
+   (listp (second args)))
+  (apply 'org-iswitchb-completing-read (concat (car args))
+ (mapcar (lambda (x) (car x)) (nth 1 args))
+ (cddr args))
+(apply 'completing-read args)))
+  (when saved-pc-mode
+(partial-completion-mode 1)

 (defun org-extract-attributes (s)
   "Extract the attributes cookie from a string and set as text property."
@@ -8890,7 +8896,6 @@ See also `org-refile-use-outline-path' and
`org-completion-use-ido'"
   (unless org-refile-target-table
 (error "No refile targets"))
   (let* ((cbuf (current-buffer))
-(partial-completion-mode nil)
 (cfn (buffer-file-name (buffer-base-buffer cbuf)))
 (cfunc (if (and org-refile-use-outline-path
 org-outline-path-complete-in-steps)


Hope it helps.

Regards,
Levin


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[O] Bug: :clock-in not working in org-capture-templates [7.9.1 (release_7.9.1-274-g2f4d76)]

2012-09-20 Thread Levin Du
Hi there,

I find :clock-in not work in org-capture-templates, with initial empty heading:

(setq org-capture-templates
  '(("j" "Journal" entry (file+datetree "")
 "* %?\n%U\n%i\n" :clock-in t :clock-resume t)))

I proposed the patch:

Modified   lisp/org-clock.el
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index b8db2d1..674a5d7 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1180,7 +1180,8 @@ make this the default behavior.)"
  (cond ((and org-clock-heading-function
  (functionp org-clock-heading-function))
 (funcall org-clock-heading-function))
-   ((looking-at org-complex-heading-regexp)
+   ((and (looking-at org-complex-heading-regexp)
+ (match-string 4))
 (replace-regexp-in-string
  "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1"
  (match-string 4)))

Thanks

Emacs  : GNU Emacs 24.2.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2012-08-31 on tchip-levcom
Package: Org-mode version 7.9.1 (release_7.9.1-274-g2f4d76 @ 
/home/zslevin/sd/emacs24-starter-kit/src/org-mode/lisp/)



Re: [Orgmode] Org mode release 6.04

2008-05-27 Thread Levin Du
I love the feature of "Editing source code example in the proper mode". It's
very handy and powerful.
I found a bug with org-mtags.el. The table of content tag in muse is
, but in org is .

If I write a simple org file with the misspelled tag:
8<8<---

* title1
* title2
8<8<---

then export using "C-c C-e h" will lead to a loop
in  org-mtags-get-tag-and-attributes.

I wish I can use  to be consistent with muse, and get a warning
from org if the tag is not supported.
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Org mode release 6.04

2008-05-27 Thread Levin Du
2008/5/28 Carsten Dominik <[EMAIL PROTECTED]>:

> Fixed thanks.
>
> I cannot make an error message when you have misspelled a tag, because Org
> cannot know
> if you have inserted that string on purpose.
>
> But the loop is fixed now, and I am using now contents instead of content.
>
> - Carsten


Thank you for your quick response and fix. I confirmed that's OK now.

And I thought I have fixed a little bug in org-export-as-html.
See this test file:
--8<8<--
#+TITLE: this is the title

* title1
* title2

good day

--8<8<--

There's no empty line or others contents after ... block.
After export (C-c C-e , the  closing tag is missing:
--8<-8<---

2 title2



  good day


--8<8<---

Here's the patch:
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 4637e8e..461ec3d 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2666,7 +2666,7 @@ lang=\"%s\" xml:lang=\"%s\">
   (setq infixed t)
   (insert "\n"))
 (insert (org-html-protect (match-string 1 line)) "\n")
-(when (and lines
+(when (or (null lines)
(not (string-match "^[ \t]*\\(:.*\\)"
   (car lines
   (setq infixed nil)

- Levin
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] [patch]org-blog.el: fix broken org-publish-blog-index

2008-05-28 Thread Levin Du
I think the API has changed a bit. Patch attched:--- a/lisp/org-blog.el
+++ b/lisp/org-blog.el
@@ -170,11 +170,12 @@ Follow up with org-publish-all to upload to the site."

 ;; pluggable index generation function for org-publish.

-(defun org-publish-blog-index (plist &optional index-filename)
+(defun org-publish-blog-index (project &optional index-filename)
   "Publish an index of all finished blog posts.
 This function is suitable for use in the :index-function keyword
 of org-publish-project-alist."
-  (let* ((posts (nreverse (sort (org-publish-get-base-files plist "*~")
'string<)))
+  (let* ((plist (cdr project))
+ (posts (nreverse (sort (org-publish-get-base-files project "*~")
'string<)))
  (base-directory (file-name-as-directory (or org-blog-directory (plist-get
plist :base-directory
  (blog-base-url (file-name-as-directory (plist-get plist :blog-base-url)))
  (blog-title (plist-get plist :blog-title))


- Levin
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] [PATCH]new org-columns-nth-allowed-value function and keys

2008-06-03 Thread Levin Du
Hi list,

While editing with Org column view, I'd like some easy navigate and modify keys.
In the patch attached (against git version), I bind vi-style key
h,j,k,l to move around, and numeric key 1-9,0 to set the nth (actually
'1' is the first, and '0' is the last) allowed value.

I mock up this by copying org-columns-next-allowed-value and modifying a bit.
Hope it is useful.

-Levin


org-colview-nth-value.diff
Description: Binary data
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[O] [PATCH] minor patch to org-babel-load-file

2013-06-18 Thread Levin Du
Hi, all

I find org-babel-load-file not work for my emacs-starter-kit  org file.
After some traces, I find that

   (org-babel-merge-params nil nil nil)

returns:

   ((:comments . "") (:shebang . "") (:cache . "") (:padline . "") (:noweb
. "") (:tangle . "") (:exports . "") (:results . ""))

which will override my default (:tangle "yes") value in
org-babel-default-header-args
and org-babel-load-file simply don't tangle source blocks without ":tangle
yes".

Below is the patch that solves this problem.

diff  a/lisp/ob-core.el b/lisp/ob-core.el
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2337,7 +2337,8 @@ parameters when merging lists."
  (lambda (hd)
(let ((key (intern (concat ":" (symbol-name hd
  (val (eval hd)))
- (setf params (cons (cons key (mapconcat 'identity val " ")) params
+ (when val
+ (setf params (cons (cons key (mapconcat 'identity val " ")) params)
  '(results exports tangle noweb padline cache shebang comments))
 params))

--
Best Regards,
Levin


[Orgmode] Let tab do org-cycle only at special place.

2007-05-23 Thread Levin Du
I've my busy tab key set to a super expand/indent function:

   (global-set-key "\t" 'ext-super-tab)

Currently in org-mode, tab is only doing indent in none headline/special 
place. I'd like to use tab only at the beginning of headline or buffer. So I 
put something like this in my org-conf.el :

(defun org-tab (&optional arg)
  "Do org-cycle only at the beginning of a headline, otherwise do
the job defined in global keymap."
  (interactive "P")
  (let* ((outline-regexp
  (if (and (org-mode-p) org-cycle-include-plain-lists)
  "\\(?:\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)"
outline-regexp))
 (bob-special (and org-cycle-global-at-bob (bobp)
   (not (looking-at outline-regexp)
(if (or bob-special
(eq arg t)
(integerp arg)
(org-at-table-p 'any)
(looking-at outline-regexp))
(org-cycle arg)
  (call-interactively (global-key-binding "\t")

(define-key org-mode-map [(tab)] 'org-tab)

Hope this is useful for someone else.

Levin


___
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode