Browse Source

Make C-c - and C-c * modify list and headline status.

Carsten Dominik 17 years ago
parent
commit
ea89f66796
5 changed files with 216 additions and 23 deletions
  1. 5 0
      ChangeLog
  2. 23 0
      ORGWEBPAGE/Changes.org
  3. 89 17
      ORGWEBPAGE/tmp/Changes.html
  4. 88 6
      org.el
  5. 11 0
      org.texi

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-03-03  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-toggle-region-items): New function.
+	(org-toggle-region-headings): New function.
+
 2008-03-01  Bastien Guerry  <bzg@altern.org>
 
 	* org.el (org-dblock-write:columnview, org-columns-capture-view):

+ 23 - 0
ORGWEBPAGE/Changes.org

@@ -64,6 +64,29 @@
      same variable also influences line splitting in items and in
      tables.
 
+   - `C-c -' has now more functions:
+     + In a table, add a hline as before
+     + In an item list, cycle bullet type as before
+     + In a normal line, turn it into an item
+     + In a headline, turn it into an item
+     + If there is an active region, turn each line into an item.
+       But if the first region line is already an item, remove
+       item markers from all lines.
+
+     Based on proposals by Bastien.
+
+   - `C-c *' has now more functions
+     + in a table, recompute, as before
+     + in a normal line, convert it to a sub heading.
+     + at an item, convert it into a subheading
+     + if there is an active region, convert all lines in the
+       region to headlines.  However, if the first lie already is
+       a heading, remove the stars from all lines int he region.
+
+     Based on proposals by Bastien.
+
+
+
 
 * Version 5.22
 

+ 89 - 17
ORGWEBPAGE/tmp/Changes.html

@@ -6,7 +6,7 @@ lang="en" xml:lang="en">
 <title>Org-mode list of User-visible changes</title>
 <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
 <meta name="generator" content="Org-mode"/>
-<meta name="generated" content="2008/02/28 17:49:40"/>
+<meta name="generated" content="2008/03/03 09:05:37"/>
 <meta name="author" content="Carsten Dominik"/>
 <style type="text/css">
   html {
@@ -56,9 +56,11 @@ lang="en" xml:lang="en">
 
 
 <p>
-This is a special search that lets you select entries by keywords or
-regular expression, using a boolean logic.  For example, the search
-string
+`C-c a s' now invokes a special agenda view that can be used
+to search notes by keyword and regular expressions.  The
+search knows the boundaries of an entry, can use simple
+Boolean logic and is reasonably fast.  For example, the
+search string
 </p>
 <p>
 <pre>
@@ -66,29 +68,50 @@ string
 </pre>
 </p>
 <p>
-will search for note entries that contain the keywords @code{computer}
-and @code{wifi}, but not the keyword @code{ethernet}, and which are also
-not matched by the regular expression @code{8\.11[bg]}, meaning to
-exclude both 8.11b and 8.11g.  If the first character of the
-search string is an asteriks, the search will lonly look at
-headlines - otherwise it will look at the headine and the
-text below it, up to the next (possibly sub-) heading.
+will search for note entries that contain the keywords
+@code{computer} and @code{wifi}, but not the keyword
+@code{ethernet}, and which are also not matched by the
+regular expression @code{8\.11[bg]}, meaning to exclude both
+8.11b and 8.11g.  If the first character of the search string
+is an asteriks, the search will only look at headlines -
+otherwise it will look at the headine and the text below it,
+up to the next (possibly sub-) heading.
 </p>
 <p>
-The default key binding for this view is `C-c a s'.
+The command searches all agenda files, and in addition the
+files listed in `org-agenda-text-search-extra-files'.
 </p>
 <p>
-You can define a custom command to do such a search only in a
-limited number of files, like this:
+I find it very useful to define a custom command to do such
+a search only in a limited number of files (my notes files),
+like this:
 </p>
 <p>
 <pre>
- ("S" "Search notes" search ""
-   ((org-agenda-files '("~/org/notes.org" "~/org/computer.org"))))    
+ ("N" "Search notes" search ""
+   ((org-agenda-files '("~/org/notes.org" "~/org/computer.org"))
+    (org-agenda-text-search-extra-files nil)))
 </pre>
 </p>
 </div>
 
+<div class="outline-4">
+<h4>Many new extensions available in the CONTRIB directory</h4>
+
+
+<p>
+The new development model already starts to pay off, a number
+of interesting extensions are now part of the distribution.
+Check the file CONTRIB/README for a list.
+</p>
+<p>
+Interesting for developers may be that there is a file
+org-id.el which implements global ID's for org-mode entries.
+These can be used in dependency implementations, for
+example.
+</p>
+</div>
+
 <div class="outline-4">
 <h4>Misc</h4>
 
@@ -106,6 +129,55 @@ don't want this command to split a line in the middle.  The
 same variable also influences line splitting in items and in
 tables.
 </p>
+</li>
+<li>
+`C-c -' has now more functions:
+<ul>
+<li>
+In a table, add a hline as before
+</li>
+<li>
+In an item list, cycle bullet type as before
+</li>
+<li>
+In a normal line, turn it into an item
+</li>
+<li>
+In a headline, turn it into an item
+</li>
+<li>
+If there is an active region, turn each line into an item.
+But if the first region line is already an item, remove
+item markers from all lines.
+
+</li>
+</ul>
+<p>Based on proposals by Bastien.
+</p>
+</li>
+<li>
+`C-c *' has now more functions
+<ul>
+<li>
+in a table, recompute, as before
+</li>
+<li>
+in a normal line, convert it to a sub heading.
+</li>
+<li>
+at an item, convert it into a subheading
+</li>
+<li>
+if there is an active region, convert all lines in the
+region to headlines.  However, if the first lie already is
+a heading, remove the stars from all lines int he region.
+
+</li>
+</ul>
+<p>Based on proposals by Bastien.
+</p>
+
+
 
 </li>
 </ul></div>
@@ -6702,6 +6774,6 @@ HTML exporter upgrade, in particular table of contents
 <div id="postamble"><p class="author"> Author: Carsten Dominik
 <a href="mailto:carsten at orgmode dot org">&lt;carsten at orgmode dot org&gt;</a>
 </p>
-<p class="date"> Date: 2008/02/28 17:49:40</p>
+<p class="date"> Date: 2008/03/03 09:05:37</p>
 </div></body>
 </html>

+ 88 - 6
org.el

@@ -26936,6 +26936,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
 (org-defkey org-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock)
 (org-defkey org-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
 (org-defkey org-mode-map "\C-c-"    'org-ctrl-c-minus)
+(org-defkey org-mode-map "\C-c*"    'org-ctrl-c-star)
 (org-defkey org-mode-map "\C-c^"    'org-sort)
 (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
 (org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
@@ -26949,7 +26950,6 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
 (org-defkey org-mode-map "\C-c'"    'org-table-edit-formulas)
 (org-defkey org-mode-map "\C-c`"    'org-table-edit-field)
 (org-defkey org-mode-map "\C-c|"    'org-table-create-or-convert-from-region)
-(org-defkey org-mode-map "\C-c*"    'org-table-recalculate)
 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
 (org-defkey org-mode-map "\C-c~"    'org-table-create-with-table.el)
 (org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region)
@@ -27429,16 +27429,39 @@ See the individual commands for more information."
    (t (if indent (newline-and-indent) (newline)))))
 
 (defun org-return-indent ()
-  (interactive)
   "Goto next table row or insert a newline and indent.
 Calls `org-table-next-row' or `newline-and-indent', depending on
 context.  See the individual commands for more information."
+  (interactive)
   (org-return t))
 
+(defun org-ctrl-c-star ()
+  "Compute table, or change heading status of lines.
+Calls `org-table-recalculate' or `org-toggle-region-headlines',
+depending on context.  This will also turn a plain list item or a normal
+line into a subheading."
+  (interactive)
+  (cond
+   ((org-at-table-p)
+    (call-interactively 'org-table-recalculate))
+   ((org-region-active-p)
+    ;; Convert all lines in region to list items
+    (call-interactively 'org-toggle-region-headings))
+   ((org-on-heading-p)
+    (org-toggle-region-headings (point-at-bol)
+				(min (1+ (point-at-eol)) (point-max))))
+   ((org-at-item-p)
+    ;; Convert to heading
+    ;; FIXME: not yet implemented
+    )
+   (t (org-toggle-region-headings (point-at-bol)
+				  (min (1+ (point-at-eol)) (point-max))))))
+
 (defun org-ctrl-c-minus ()
-  "Insert separator line in table or modify bullet type in list.
-Calls `org-table-insert-hline' or `org-cycle-list-bullet',
-depending on context."
+  "Insert separator line in table or modify bullet status of line.
+Also turns a plain line or a region of lines into list items.
+Calls `org-table-insert-hline', `org-toggle-region-items', or
+`org-cycle-list-bullet', depending on context."
   (interactive)
   (cond
    ((org-at-table-p)
@@ -27449,10 +27472,69 @@ depending on context."
       (beginning-of-line 1)
       (if (looking-at "\\*+ ")
 	  (replace-match (concat (make-string (- (match-end 0) (point)) ?\ ) "- ")))))
+   ((org-region-active-p)
+    ;; Convert all lines in region to list items
+    (call-interactively 'org-toggle-region-items))
    ((org-in-item-p)
     (call-interactively 'org-cycle-list-bullet))
-   (t (error "`C-c -' does have no function here."))))
+   (t (org-toggle-region-items (point-at-bol)
+			       (min (1+ (point-at-eol)) (point-max))))))
 
+(defun org-toggle-region-items (beg end)
+  "Convert all lines in region to list items.
+If the first line is already an item, convert all list items in the region
+to normal lines."
+  (interactive "r")
+  (let (l2 l)
+    (save-excursion
+      (goto-char end)
+      (setq l2 (org-current-line))
+      (goto-char beg)
+      (beginning-of-line 1)
+      (setq l (1- (org-current-line)))
+      (if (org-at-item-p)
+	  ;; We already have items, de-itemize
+	  (while (< (setq l (1+ l)) l2)
+	    (when (org-at-item-p)
+	      (goto-char (match-beginning 2))
+	      (delete-region (match-beginning 2) (match-end 2))
+	      (and (looking-at "[ \t]+") (replace-match "")))
+	    (beginning-of-line 2))
+	(while (< (setq l (1+ l)) l2)
+	  (unless (org-at-item-p)
+	    (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
+		(replace-match "\\1- \\2")))
+	  (beginning-of-line 2))))))
+			
+(defun org-toggle-region-headings (beg end)
+  "Convert all lines in region to list items.
+If the first line is already an item, convert all list items in the region
+to normal lines."
+  (interactive "r")
+  (let (l2 l)
+    (save-excursion
+      (goto-char end)
+      (setq l2 (org-current-line))
+      (goto-char beg)
+      (beginning-of-line 1)
+      (setq l (1- (org-current-line)))
+      (if (org-on-heading-p)
+	  ;; We already have headlines, de-star them
+	  (while (< (setq l (1+ l)) l2)
+	    (when (org-on-heading-p t)
+	      (and (looking-at outline-regexp) (replace-match "")))
+	    (beginning-of-line 2))
+	(let* ((stars (save-excursion
+			(re-search-backward org-complex-heading-regexp nil t)
+			(or (match-string 1) "*")))
+	       (add-stars (if org-odd-levels-only "**" "*"))
+	       (rpl (concat stars add-stars " \\2")))
+	  (while (< (setq l (1+ l)) l2)
+	    (unless (org-on-heading-p)
+	      (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
+		  (replace-match rpl)))
+	    (beginning-of-line 2)))))))
+  
 (defun org-meta-return (&optional arg)
   "Insert a new heading or wrap a region in a table.
 Calls `org-insert-heading' or `org-table-wrap-region', depending on context.

+ 11 - 0
org.texi

@@ -896,6 +896,13 @@ in each entry), by priority, and each of these in reverse order.  You
 can also supply your own function to extract the sorting key.  With a
 @kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
 C-u} prefixes, duplicate entries will also be removed.
+@kindex C-c *
+@item C-c *
+Turn a normal line or plain list item into a headline (so that it
+becomes a subheading at its location).  Also turn a headline into a
+normal line by removing the stars.  If there is an active region, turn
+all lines in the region into headlines.  Or, if the first line is a
+headline, remove the stars from all headlines in the region.
 @end table
 
 @cindex region, active
@@ -1201,6 +1208,10 @@ an ordered list, make sure the numbering is ok.
 Cycle the entire list level through the different itemize/enumerate
 bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).
 With prefix arg, select the nth bullet from this list.
+If there is an active region when calling this, all lines will be
+converted to list items.  If the first line already was a list item, any
+item markers will be removed from the list.  Finally, even without an
+active region, a normal line will be converted into a list item.
 @end table
 
 @node Drawers, orgstruct-mode, Plain lists, Document structure