diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index d1e58ac4e..99ef86cd4 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -15,6 +15,13 @@ :VISIBILITY: content :END: +** Overview + +- Statistics cookies [/] and [%] for TODO entries +- Editing source code example in the proper mode +- iCalendar now defines proper UIDs for entries +- New properties for customizing subtree export + ** Incompatible changes - The default of the variable `org-tags-match-list-sublevels' is @@ -30,7 +37,7 @@ *** Statistics for TODO entries The [/] and [%] cookies have already provided statistics for -checkboxes. Now they do the same also for TODO entries. So if a +checkboxes. Now they do the same also for TODO entries. If a headline contains either cookie, changing the TODO state of any direct child will trigger an update of this cookie. Children that are neither TODO nor DONE are ignored. @@ -38,7 +45,7 @@ that are neither TODO nor DONE are ignored. There have already been requests to automatically switch the parent headline to DONE when all children are done. I am not making this a default feature, because one needs to make many -decisions about which keyword to use etc. Instead of a complex +decisions about which keyword to use, etc. Instead of a complex customization variable, I am providing a hook that can be used. This hook will be called each time a TODO statistics cookie is updated, with the cursor in the corresponding line. Each @@ -56,28 +63,50 @@ implementation: (add-hook 'org-after-todo-statistics-hook 'org-summary-todo) #+end_src +*** Editing source code example in the proper mode + +If you are writing a document with source code examples, you can +include these examples into a =#+BEGIN_SRC lang ... #+END_SRC= or +(with the org-mtags module loaded) a = + + * org.el (org-edit-src-example, org-find-src-example-start) + (org-protect-source-example, org-edit-special): New functions. + 2008-05-24 Carsten Dominik * org-publish.el (org-publish-project-alist): Fix typo in diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 7e270f827..d1342d1d4 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1736,7 +1736,8 @@ backends, it converts the segment into an EXAMPLE segment." ;; Free up the protected stuff (goto-char (point-min)) (while (re-search-forward "^," nil t) - (replace-match "")) + (replace-match "") + (end-of-line 1)) (if (functionp mode) (funcall mode) (fundamental-mode)) diff --git a/lisp/org.el b/lisp/org.el index 138f12508..b65537650 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2744,8 +2744,6 @@ After a match, the following groups carry important information: ("content" org-startup-folded content) ("hidestars" org-hide-leading-stars t) ("showstars" org-hide-leading-stars nil) - ("indent" org-adapt-indentation t) - ("noindent" org-adapt-indentation nil) ("odd" org-odd-levels-only t) ("oddeven" org-odd-levels-only nil) ("align" org-startup-align-all-tables t) @@ -5333,6 +5331,77 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive." table) (lambda (a b) (funcall comparefun (car a) (car b)))))) +;;; Editing source examples + +(defun org-edit-src-example () + "Edit the source code example at point. +An indirect buffer is created, and that buffer is then narrowed to the +example at point and switched to the correct language mode. When done, +exit by killing the buffer with \\[kill-buffer]. It is important to exit +in this way because some Org quoting of the example will take place." + (interactive) + (let ((line (org-current-line)) + (case-fold-search t) + (msg (substitute-command-keys + "Edit, then kill this indirect buffer with \\[kill-buffer]")) + beg end) + (if (not (org-find-src-example-start)) + ;; not at an example + nil + (if (not (save-excursion + (goto-char (point-at-bol)) + (or (looking-at "#\\+begin_src[ \t]+\\([^ \t\n]+\\)") + (looking-at "[ \t]*\\)" nil t) + (error "Cannot find end of src")) + (setq end (match-beginning 0)) + (goto-line line) + (if (get-buffer "*Org Edit Src Example*") + (kill-buffer "*Org Edit Src Example*")) + (switch-to-buffer (make-indirect-buffer (current-buffer) + "*Org Edit Src Example*")) + (narrow-to-region beg end) + (funcall lang-f) + (goto-char (point-min)) + (while (re-search-forward "^," nil t) + (replace-match "")) + (goto-char (point-min)) + (goto-line line) + (org-add-hook 'kill-buffer-hook 'org-protect-source-example nil 'loc) + (org-set-local 'header-line-format msg) + (message "%s" msg) + t))) + +(defun org-find-src-example-start () + "If point is in a src example, move to the beginning of it. +If not, just return nil." + (let ((re "^\\(#\\+begin_src\\|[ \t]*= (point-at-eol) pos)) + (goto-char p1) + (goto-char pos) + nil)))) + +(defun org-protect-source-example () + "Protect example lines with Org syntax." + (unless (> (point-min) 1) + (error "This buffer is not narrowed, something is wrong...")) + (goto-char (point-min)) + (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t) + (replace-match ",\\1"))) + ;;;; Plain list items, including checkboxes ;;; Plain list items @@ -12202,7 +12271,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." (org-defkey org-mode-map "\C-c " 'org-table-blank-field) (org-defkey org-mode-map "\C-c+" 'org-table-sum) (org-defkey org-mode-map "\C-c=" 'org-table-eval-formula) -(org-defkey org-mode-map "\C-c'" 'org-table-edit-formulas) +(org-defkey org-mode-map "\C-c'" 'org-edit-special) (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 [(control ?#)] 'org-table-rotate-recalc-marks) @@ -12570,6 +12639,18 @@ See the individual commands for more information." (org-table-paste-rectangle) (org-paste-subtree arg))) +(defun org-edit-special () + "Call a special editor for the stuff at point. +When at a table, call the formula editor with `org-table-edit-formulas'. +When at the first line of an src example, call `org-edit-src-example'." + (interactive) + (if (org-at-table-p) + (call-interactively 'org-table-edit-formulas) + (or (org-edit-src-example) + (error "%s" + (substitute-command-keys + "\\[org-edit-special] can do nothing useful here."))))) + (defun org-ctrl-c-ctrl-c (&optional arg) "Set tags in headline, or update according to changed information at point. @@ -12850,7 +12931,7 @@ See the individual commands for more information." ("Calculate" ["Set Column Formula" org-table-eval-formula (org-at-table-p)] ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="] - ["Edit Formulas" org-table-edit-formulas (org-at-table-p)] + ["Edit Formulas" org-edit-special (org-at-table-p)] "--" ["Recalculate line" org-table-recalculate (org-at-table-p)] ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"] @@ -12915,7 +12996,8 @@ See the individual commands for more information." ["Convert to odd levels" org-convert-to-odd-levels t] ["Convert to odd/even levels" org-convert-to-oddeven-levels t]) ("Editing" - ["Emphasis..." org-emphasize t]) + ["Emphasis..." org-emphasize t] + ["Edit Source Example" org-edit-special t]) ("Archive" ["Toggle ARCHIVE tag" org-toggle-archive-tag t] ; ["Check and Tag Children" (org-toggle-archive-tag (4))