Re: [Orgmode] Programmers, use org to write your doc strings...
Great idea. I have wanted org in emacs-lisp-mode but was stymied by the difficulty of getting org to understand semicolons. It what ways is this an improvement over orgtbl and orgstruct*? Ideally we could put headlines in there also and have them searchable in org :). On 2010-03-02, Paul Sexton wrote: > Hi > > I think org is a good platform for writing documentation for > source code. The "babel" module is one approach, but it presumes > that org is the dominant major mode, and the actual source code > is divided into snippets here and there. > > I wanted to look into another way of doing it: the source code's > mode is dominant, with snippets of org mode here and there. Babel > in reverse if you will. > > I have used mmm-mode, which is part of nXhtml mode, which you > can download at: > > http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl > > I have managed to get it working for common lisp. Users of other > programming languages should easily be able to achieve the same > effect by modifying the elisp code below. > > In a lisp buffer, documentation strings use org mode as their > major mode, while the rest of the file uses lisp-mode. All the > fontification works, as does formatting of bulleted lists > etc. Hyperlink overlays don't work (you see [[the whole][link]] > rather than the short form), but the links themselves work. > > We define a docstring as: > 1. A string which emacs has fontified using the font lock >docstring face > 2. A string that comes after '(:documentation ' > 3. A string whose first three characters are ### > > MMM-mode sometimes seems to need a bit of a poke to recognise new > docstrings. If it's not recognising things that it should, press > ctrl-` to refresh it. > > My motivation is that I have written a "doxygen"-like program for > common lisp, called CLOD, whose output is an org mode file. You > can use org mode markup in common lisp docstrings, and the markup > will be understood when the docstrings are read by CLOD. Now, I > can edit those docstrings within the lisp source file and get all > org's fontification, at formatting of bulleted lists, hyperlinks, > etc. All without leaving emacs. > > Paul > > > -contents of .emacs follows--- > > > (add-to-list 'load-path "/path/to/mmm-mode")) > (require 'mmm-auto) > (setq mmm-global-mode 'maybe) > (mmm-add-mode-ext-class 'lisp-mode nil 'org-submode) > (mmm-add-mode-ext-class 'slime-mode nil 'org-submode) > ;; The above, using major mode symbols, didn't seem to work for > ;; me so I also added these line (regexp uses same format as > ;; major-mode-alist): > (mmm-add-mode-ext-class nil "\\.lisp$" 'org-submode) > (mmm-add-mode-ext-class nil "\\.asd$" 'org-submode) > (setq mmm-submode-decoration-level 2) > > ;; This prevents transient loss of fontification on first > ;; calling `mmm-ify-by-class' > (defadvice mmm-ify-by-class (after refontify-after-mmm > activate compile) > (font-lock-fontify-buffer)) > > ;; bind control-backquote to "refresh" MMM-mode in current buffer. > (global-set-key [?\C-`] (lambda () (interactive) > (mmm-ify-by-class 'org-submode))) > > ;; And the definition of 'org-submode > (mmm-add-group 'org-submode >'((org-submode1 > :submode org-mode > ;; This face supplies a background colour for org > ;; parts of the buffer. Customizable. > :face mmm-declaration-submode-face > :front "\"" > :back "[^\\]\"" > :back-offset 1 > :front-verify check-docstring-match > :end-not-begin t) > (org-submode-2 > :submode org-mode > :face mmm-declaration-submode-face > ;; Match '(:documentation "...")' docstrings > :front "(:documentation[\t\n ]+\"" > :back "[^\\]\"" > :back-offset 1 > :end-not-begin t))) > > (defun face-at (pos) > (save-excursion > (goto-char pos) > (face-at-point))) > > > (defun check-docstring-match () > (interactive) > (let ((beg (match-beginning 0)) > (end (match-end 0))) > (cond >;; Docstring if emacs has fontified it in 'docstring' face >((eql (face-at end) 'font-lock-doc-face) > t) >;; Docstring if the first three characters after the opening >;; quote are "###" >((string= (buffer-substring end (+ 3 end)) "###") > t) >(t > nil > > > > > > > ___ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > -- Q: How many CDC "scientists" does it take to change a lightbulb? A: "You only think it's dark." [CDC has denied a deadly disease for 25 years] == Retrovirus: http://
[Orgmode] Programmers, use org to write your doc strings...
Hi I think org is a good platform for writing documentation for source code. The "babel" module is one approach, but it presumes that org is the dominant major mode, and the actual source code is divided into snippets here and there. I wanted to look into another way of doing it: the source code's mode is dominant, with snippets of org mode here and there. Babel in reverse if you will. I have used mmm-mode, which is part of nXhtml mode, which you can download at: http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl I have managed to get it working for common lisp. Users of other programming languages should easily be able to achieve the same effect by modifying the elisp code below. In a lisp buffer, documentation strings use org mode as their major mode, while the rest of the file uses lisp-mode. All the fontification works, as does formatting of bulleted lists etc. Hyperlink overlays don't work (you see [[the whole][link]] rather than the short form), but the links themselves work. We define a docstring as: 1. A string which emacs has fontified using the font lock docstring face 2. A string that comes after '(:documentation ' 3. A string whose first three characters are ### MMM-mode sometimes seems to need a bit of a poke to recognise new docstrings. If it's not recognising things that it should, press ctrl-` to refresh it. My motivation is that I have written a "doxygen"-like program for common lisp, called CLOD, whose output is an org mode file. You can use org mode markup in common lisp docstrings, and the markup will be understood when the docstrings are read by CLOD. Now, I can edit those docstrings within the lisp source file and get all org's fontification, at formatting of bulleted lists, hyperlinks, etc. All without leaving emacs. Paul -contents of .emacs follows--- (add-to-list 'load-path "/path/to/mmm-mode")) (require 'mmm-auto) (setq mmm-global-mode 'maybe) (mmm-add-mode-ext-class 'lisp-mode nil 'org-submode) (mmm-add-mode-ext-class 'slime-mode nil 'org-submode) ;; The above, using major mode symbols, didn't seem to work for ;; me so I also added these line (regexp uses same format as ;; major-mode-alist): (mmm-add-mode-ext-class nil "\\.lisp$" 'org-submode) (mmm-add-mode-ext-class nil "\\.asd$" 'org-submode) (setq mmm-submode-decoration-level 2) ;; This prevents transient loss of fontification on first ;; calling `mmm-ify-by-class' (defadvice mmm-ify-by-class (after refontify-after-mmm activate compile) (font-lock-fontify-buffer)) ;; bind control-backquote to "refresh" MMM-mode in current buffer. (global-set-key [?\C-`] (lambda () (interactive) (mmm-ify-by-class 'org-submode))) ;; And the definition of 'org-submode (mmm-add-group 'org-submode '((org-submode1 :submode org-mode ;; This face supplies a background colour for org ;; parts of the buffer. Customizable. :face mmm-declaration-submode-face :front "\"" :back "[^\\]\"" :back-offset 1 :front-verify check-docstring-match :end-not-begin t) (org-submode-2 :submode org-mode :face mmm-declaration-submode-face ;; Match '(:documentation "...")' docstrings :front "(:documentation[\t\n ]+\"" :back "[^\\]\"" :back-offset 1 :end-not-begin t))) (defun face-at (pos) (save-excursion (goto-char pos) (face-at-point))) (defun check-docstring-match () (interactive) (let ((beg (match-beginning 0)) (end (match-end 0))) (cond ;; Docstring if emacs has fontified it in 'docstring' face ((eql (face-at end) 'font-lock-doc-face) t) ;; Docstring if the first three characters after the opening ;; quote are "###" ((string= (buffer-substring end (+ 3 end)) "###") t) (t nil ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Precision setting for spreadsheet calculation
Hi Carsten Michael Brand wrote: Yes, within a few days I will come back with this and/or a texinfo patch for the Org info manual, at least chapter "3.5.2 Formula syntax for Calc". The patch below is my proposal for the manual. Please feel free to improve it. I also played around quite a bit with the precision settings and will put the resulting examples into the Worg FAQ. But I would like to postpone my Worg FAQ update because its link to the manual would be confusing before the manual update itself will have been made. Is there a small issue with the behavior of the section link http://orgmode.org/manual/index.html#Top ? With Firefox 3.0.5 it sometimes jumps to where the html source fragment lies like expected but sometimes it jumps to where the html source fragment lies which could be annoying. Michael patch for org.texi, `---' file was taken from org-version 6.34c: = --- a/doc/org.texi 2010-01-18 00:10:46.0 +0100 +++ b/doc/org.texi 2010-03-02 20:00:00.0 +0100 @@ -2128,8 +2128,11 @@ @code{org-calc-default-modes}. @example -p20 @r{switch the internal precision to 20 digits} -n3 s3 e2 f4 @r{normal, scientific, engineering, or fixed display format} +p20 @r{set the internal Calc calculation precision to 20 digits} +n3 s3 e2 f4 @r{Normal, scientific, engineering, or fixed} + @r{format of the result of Calc passed back to Org.} + @r{Calc formatting is unlimited in precision as} + @r{long as the Calc calculation precision is greater.} D R @r{angle modes: degrees, radians} F S @r{fraction and symbolic modes} N @r{interpret all fields as numbers, use 0 for non-numbers} @@ -2139,8 +2142,16 @@ @end example @noindent -In addition, you may provide a @code{printf} format specifier to -reformat the final result. A few examples: +Unless you use large integer numbers or high-precision-calculation +and -display for floating point numbers you may alternatively provide a +...@code{printf} format specifier to reformat the Calc result after it has been +passed back to Org instead of letting Calc already do the +formatt...@footnote{the @code{printf} reformatting is limited in precision +because the value passed to it is converted into an @code{integer} or +...@code{double}. The @code{integer} is limited in size by truncating the +signed value to 32 bits. The @code{double} is limited in precision to 64 +bits overall which leaves approximately 16 significant decimal digits.}. +A few examples: @example $1+$2@r{Sum of first and second field} = ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Bug in LaTeX export of org-html-entities?
I think I forgot to state the actual problem, cosider the following org-file: * An example \Rightarrow foobar some text The produced LaTeX code is: % Created 2010-03-02 Tue 12:53 \documentclass[11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{longtable} \usepackage{hyperref} \providecommand{\alert}[1]{\textbf{#1}} \title{test} \author{} \date{02 March 2010} \begin{document} \maketitle \setcounter{tocdepth}{3} \tableofcontents \vspace*{1cm} \section{An example \Rightarrow foobar} \label{sec-1} some text \end{document} As you can see it includes \Rightarrow instead of $\Rightarrow$ and the check in the export function to accomplish that is the first one, but that one uses member to check for an entry of the form ("Rightarrow") in the org-html-entities list which does not exist and even if it would exist the elisp-code to procude the LaTeX code would call cdar on the list ("Rightarrow") which results in nil and the second part of the or-statement is executed, i.e. it always executes the second part of the or-statement. Geralt. ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Bug in LaTeX export of org-html-entities?
Hi, it's been a few days and still no response, am I the only one who thinks there's something wrong with the export of the special entities preceded by a backslash, like \Rightarrow? Geralt. ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Exporting of ascii diagrams in pdf broken
Hi, in the org version shipped with Emacs 23.1 everything that looked like a table in #+BEGIN_EXAMPLE blocks is broken, although it was supposedly fixed, the following example still fails with the latest version from the git repo (commit f0f5119): #+BEGIN_EXAMPLE V +-+ | | | Some text | | | +-+ #+END_EXAMPLE The generated LaTeX code is: % Created 2010-03-02 Tue 12:39 \documentclass[11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{longtable} \usepackage{hyperref} \providecommand{\alert}[1]{\textbf{#1}} \title{V} \author{} \date{02 March 2010} \begin{document} \maketitle \setcounter{tocdepth}{3} \tableofcontents \vspace*{1cm} \begin{verbatim} \begin{center} \begin{tabular}{|l|} \hline Some text \\ \hline \end{tabular} \end{center}\end{verbatim} \end{document} HTH, Geralt. ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] MobileOrg Android 0.1_alpha
Hi Matthew Matthew Jones writes: > Hi Sven, are you connecting via https? What is your URI connect string? I > think it should work fine but I'll set up an account and test it out > tonight... > if you have access to debug information via USB Debugging that would also be > helpful. Oh my god. That's really silly. Just installed USB Debugging. That led me to the solution: Ähem ... The URL field has to point to the index.org file, not to the directory. That was a misunderstanding. Now it's working. I will try to use MobileOrg and send you feedback. Thanks again, Sven ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: org-prefere-future for other applications
Carsten Dominik writes: > On Feb 27, 2010, at 1:29 PM, Łukasz Stelmach wrote: >> I've tried to rearrange org-read-date and some other helper function >> to make them usable from other applications which might not want to >> prefere future dates. Unfortunatelly I can't do it without making >> org-read- date *require* additional argument (prefer-future) >> everytime it is called in orgmode like this: >> >> (org-read-date ... org-read-date-prefer-future) > > > Ah, may be this is what this is about: > > (defun org-my-read-date (&optional prefer-future) >(let ((org-read-date-prefer-future prefer-future)) > (org-read-date))) > > ? So this is dynamic soping? Thats what I needed, thanks. Scoping is one of subjects that always gives me a bit of a headache, no matter what language I use. Now with a function like this: --8<---cut here---start->8--- (defun stl/org-read-date (&optional with-time to-time from-string prompt default-time default-input prefer-future) "A wrapper around `org-read-date' to make it ignore the global `org-read-date-prefer-future' value." (let ((org-read-date-prefer-future prefer-future)) (org-read-date with-time to-time from-string prompt default-time default-input))) --8<---cut here---end--->8--- and a two others --8<---cut here---start->8--- (defun stl/org-ledger-ask-cleared () (let (c) (while (not (member (setq c (read-char "Cleared [Y/n/p]?")) '(?y ?n ?p ?\n ?\r ?\ (cond ((eq c ?n) "") ((eq c ?p) "! ") (t "* " (defun stl/org-ledger-read-invoice () (let ((c (read-string "Invoice number:"))) (if (string-match ".+" c) (concat "(" c ") ") ""))) --8<---cut here---end--->8--- and a template: --8<---cut here---start->8--- ("Expense" ?E "%(format-time-string \"%Y-%m-%d\" (stl/org-read-date nil 'to-time)) %(stl/org-ledger-ask-cleared)%(stl/org-ledger-read-invoice)%^{Description} %^{Debit||Expense:Cash|Assets:Checking|Liabilities:Visa} %^{Credit||Expense:Food|Expense:Supplies}\t%^{Amount}\n\n%!" "~/org/ledger.dat" bottom) --8<---cut here---end--->8--- I can use remember to add transactions to my ledger *without* havig to specify full date (most of times you register transactions from the past, right?). Cool :-) -- Miłego dnia, Łukasz Stelmach ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode