Skip to content

Commit 1761053

Browse files
committed
Merge branch 'master' of github.com:jceb/vim-orgmode
2 parents 7e49229 + 815fa9c commit 1761053

28 files changed

+2088
-471
lines changed

doc/orgguide.txt

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ Sparse trees~
440440

441441
------------------------------------------------------------------------------
442442
Plain lists~
443+
*orgguide-plain-list*
443444
Within an entry of the outline tree, hand-formatted lists can provide
444445
additional structure.
445446

446-
Not yet implemented in vim-orgmode~
447447
They also provide a way to create lists of checkboxes (see section
448448
|orgguide-checkboxes|).
449449

@@ -685,12 +685,59 @@ Priorities~
685685

686686
------------------------------------------------------------------------------
687687
Breaking tasks down into subtasks~
688-
Not yet implemented in vim-orgmode~
688+
689+
It is often advisable to break down large tasks into smaller, manageable
690+
subtasks. You can do this by creating an outline tree below a TODO item,
691+
with detailed subtasks on the tree. To keep the overview over the
692+
fraction of subtasks that are already completed, insert either ‘[/]’ or
693+
‘[%]’ anywhere in the headline. These cookies will be updated each time
694+
the TODO status of a child changes, or when pressing C-c C-c on the
695+
cookie. For example:
696+
697+
>
698+
* Organize Party [33%]
699+
** TODO Call people [1/2]
700+
*** TODO Peter
701+
*** DONE Sarah
702+
** TODO Buy food
703+
** DONE Talk to neighbor
704+
<
705+
706+
<localleader>c# Update the checkboxes status of current heading. It also
707+
update the heading status too.
689708

690709
------------------------------------------------------------------------------
691710
Checkboxes~
692711
*orgguide-checkboxes*
693-
Not yet implemented in vim-orgmode~
712+
713+
Every item in a plain list (see section |orgguide-plain-list|)
714+
can be made into a checkbox by starting it with the string ‘[ ]’.
715+
Checkboxes are not included into the global TODO list, so they are often
716+
great to split a task into a number of simple steps. Here is an example
717+
of a checkbox list.
718+
719+
>
720+
* TODO Organize party [1/3]
721+
- [-] call people [1/2]
722+
- [ ] Peter
723+
- [X] Sarah
724+
- [X] order food
725+
- [ ] think about what music to play
726+
<
727+
728+
Checkboxes work hierarchically, so if a checkbox item has children that
729+
are checkboxes, toggling one of the children checkboxes will make the
730+
parent checkbox reflect if none, some, or all of the children are
731+
checked.
732+
733+
The following commands work with checkboxes:
734+
735+
<localleader>cc Toggle checkbox status or (with prefix arg) checkbox
736+
presence at point.
737+
738+
<localleader>cn Insert a new checkbox below current line.
739+
740+
<localleader>cN Insert a new checkbox above current line.
694741

695742
==============================================================================
696743
TAGS *orgguide-tags*

ftplugin/org.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ let g:loaded_org = 1
3232

3333
" Default org plugins that will be loaded (in the given order)
3434
if ! exists('g:org_plugins') && ! exists('b:org_plugins')
35-
let g:org_plugins = ['ShowHide', '|', 'Navigator', 'EditStructure', '|', 'Hyperlinks', '|', 'Todo', 'TagsProperties', 'Date', 'Agenda', 'Misc', '|', 'Export']
35+
let g:org_plugins = ['ShowHide', '|', 'Navigator', 'EditStructure', '|', 'Hyperlinks', '|', 'Todo', 'TagsProperties', 'Date', 'Agenda', 'Misc', '|', 'Export', 'EditCheckbox']
3636
endif
3737

3838
if ! exists('g:org_syntax_highlight_leading_stars') && ! exists('b:org_syntax_highlight_leading_stars')
3939
let g:org_syntax_highlight_leading_stars = 1
4040
endif
4141

42+
" expand tab for counting level of checkbox"{{{
43+
setlocal expandtab
44+
setlocal tabstop=4
45+
setlocal sw=4
46+
"}}}
4247

4348
" Menu and document handling {{{
4449
function! <SID>OrgRegisterMenu()

ftplugin/orgmode/_vim.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
REPEAT_EXISTS = bool(int(vim.eval('exists("*repeat#set()")')))
2626
TAGSPROPERTIES_EXISTS = False
2727

28+
cache_heading = None
2829

2930
def realign_tags(f):
3031
u"""
@@ -175,8 +176,15 @@ def indent_orgmode():
175176
d = ORGMODE.get_document()
176177
heading = d.current_heading(line - 1)
177178
if heading and line != heading.start_vim:
178-
vim.command((u'let b:indent_level = %d' % (heading.level + 1))
179-
.encode(u'utf-8'))
179+
heading.init_checkboxes()
180+
checkbox = heading.current_checkbox()
181+
if checkbox:
182+
print checkbox
183+
vim.command((u'let b:indent_level = %d' % (checkbox.level + 6))
184+
.encode(u'utf-8'))
185+
else:
186+
vim.command((u'let b:indent_level = %d' % (heading.level + 1))
187+
.encode(u'utf-8'))
180188

181189

182190
def fold_text(allow_dirty=False):
@@ -230,8 +238,18 @@ def fold_orgmode(allow_dirty=False):
230238
heading = d.find_current_heading(line - 1)
231239
else:
232240
heading = d.current_heading(line - 1)
241+
242+
# if cache_heading != heading:
243+
# heading.init_checkboxes()
244+
# checkbox = heading.current_checkbox()
245+
246+
# cache_heading = heading
233247
if heading:
234-
if line == heading.start_vim:
248+
# if checkbox:
249+
# vim.command((u'let b:fold_expr = ">%d"' % heading.level + checkbox.level).encode(u'utf-8'))
250+
if 0:
251+
pass
252+
elif line == heading.start_vim:
235253
vim.command((u'let b:fold_expr = ">%d"' % heading.level).encode(u'utf-8'))
236254
#elif line == heading.end_vim:
237255
# vim.command((u'let b:fold_expr = "<%d"' % heading.level).encode(u'utf-8'))
@@ -251,7 +269,6 @@ def date_to_str(date):
251269
u'%Y-%m-%d %a'.encode(u'utf-8')).decode(u'utf-8')
252270
return date
253271

254-
255272
class OrgMode(object):
256273
u""" Vim Buffer """
257274

@@ -338,6 +355,7 @@ def register_plugin(self, plugin):
338355
return self._plugins[plugin]
339356
except Exception, e:
340357
echoe(u'Unable to activate plugin: %s' % plugin)
358+
echoe(u"%s" % e)
341359
if self.debug:
342360
import traceback
343361
echoe(traceback.format_exc())
@@ -385,4 +403,5 @@ def start(self):
385403

386404
ORGMODE = OrgMode()
387405

406+
388407
# vim: set noexpandtab:

ftplugin/orgmode/liborgmode/agenda.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
22

33
u"""
4-
Agenda
5-
~~~~~~~~~~~~~~~~~~
4+
Agenda
5+
~~~~~~~~~~~~~~~~~~
66
7-
The agenda is one of the main concepts of orgmode. It allows to
7+
The agenda is one of the main concepts of orgmode. It allows to
88
collect TODO items from multiple org documents in an agenda view.
99
1010
Features:
@@ -43,7 +43,8 @@ def get_next_week_and_active_todo(self, documents):
4343
filtered = []
4444
for i, document in enumerate(documents):
4545
# filter and return headings
46-
tmp = filter_items(document.all_headings(),
46+
tmp = filter_items(
47+
document.all_headings(),
4748
[is_within_week_and_active_todo])
4849
filtered.extend(tmp)
4950
return sorted(filtered)
@@ -56,7 +57,8 @@ def get_timestamped_items(self, documents):
5657
filtered = []
5758
for i, document in enumerate(documents):
5859
# filter and return headings
59-
tmp = filter_items(document.all_headings(),
60+
tmp = filter_items(
61+
document.all_headings(),
6062
[contains_active_date])
6163
filtered.extend(tmp)
6264
return sorted(filtered)

ftplugin/orgmode/liborgmode/base.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,48 @@ def extend(self, other):
117117
self._changed()
118118

119119

120+
def get_domobj_range(content=[], position=0, direction=Direction.FORWARD, identify_fun=None):
121+
u"""
122+
Get the start and end line number of the dom obj lines from content.
123+
124+
:content: String to be recognized dom obj
125+
:positon: Line number in content
126+
:direction: Search direction
127+
:identify_fun: A identify function to recognize dom obj(Heading, Checkbox) title string.
128+
129+
:return: Start and end line number for the recognized dom obj.
130+
"""
131+
len_cb = len(content)
132+
133+
if position < 0 or position > len_cb:
134+
return (None, None)
135+
136+
tmp_line = position
137+
start = None
138+
end = None
139+
140+
# Search heading upwards
141+
if direction == Direction.FORWARD:
142+
while tmp_line < len_cb:
143+
if identify_fun(content[tmp_line]) is not None:
144+
if start is None:
145+
start = tmp_line
146+
elif end is None:
147+
end = tmp_line - 1
148+
if start is not None and end is not None:
149+
break
150+
tmp_line += 1
151+
else:
152+
while tmp_line >= 0 and tmp_line < len_cb:
153+
if identify_fun(content[tmp_line]) is not None:
154+
if start is None:
155+
start = tmp_line
156+
elif end is None:
157+
end = tmp_line - 1
158+
if start is not None and end is not None:
159+
break
160+
tmp_line -= 1 if start is None else -1
161+
162+
return (start, end)
163+
120164
# vim: set noexpandtab:

0 commit comments

Comments
 (0)