Re: [O] noweb and :var statements
Hi Sebastian, Thanks for your help. I was running with "-Q" but must have been making some other mistakes. It does work. As for your other email... I do know several tangles can go to the same file. And I may be using <> incorrectly, but I'm using it for the following reasons: 1) I'd like to bury code that must run first but is inconsequential at the bottom of the Org file. Noweb lets me have a tangled <> at the top, and then hide the lengthy <> code elsewhere. Is this a correct use case? 2) I'd like to import 10 tables, so I thought a noweb function might be useful for code reuse. I finally got the behavior I'm looking for. What I need to remember/understand is that <> just pastes the body, and <> evaluates the function. From this, my Python code needs to generate Python code! I now have the following MWE that behaves as I want both for in-buffer C-c C-c eval of main code block and tangled results. The key bit of code is the last babel block. Thanks for your help, -k. * MWE init #+BEGIN_SRC emacs-lisp :results output (setq org-confirm-babel-evaluate nil) (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (print (emacs-version)) (print (org-version nil t)) (org-babel-tangle) #+END_SRC * Main Project #+NAME: main #+BEGIN_SRC python :tangle MWE3.py :noweb yes :results output <> print(t42.sum()) print(t100.sum()) #+END_SRC #+RESULTS: main : 84.0 : 100.0 * Data Tables #+NAME: table_42 | foo | |-| | 42 | | 42 | #+NAME: table_100 | bar | |-| | 100 | * Setup #+NAME: setup #+BEGIN_SRC python :noweb yes import numpy as np <> <> #+END_SRC * Table Import Code #+NAME: import_table_to_varname #+BEGIN_SRC python :var table=table_42 :var varname="foo" :noweb yes :results output print(varname + "=np.array(" + str(table) + ").astype(np.float).flatten()") #+END_SRC
Re: [O] Shameless plug: blog series on how to use org mode features (PIM)
This is great, thanks for sharing! :) Karl Voit writes: > Hi! > > I created a series of my own blog articles on how I am using > features from Org mode. > > It's not related to the manual, it's related to "how to combine misc > features for everyday's work". > > Maybe you find a few tricks here or there: > https://karl-voit.at/2019/09/25/using-orgmode/ > > I'll add more articles in the future: > - Categories versus tags (soon) > - Using many or few Org mode files? > - Limiting the stuff visible on my agenda > - Finding stuff within Org mode > - ... > > Comments welcome! > > > PS: Sorry for the advertisement in case you're feeling upset. I'm not earning > any money with my web page though! -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] Feature request: add leading zeroes to align ordered lists with indexes of different length
This can use similar solution like ~org-num-mode~ which is already built-in of Org Mode. You can check it out. Might you can share it after you implemented an add-on. Davi Ramos writes: > I don't think it would be as visually pleasant, but I would be grateful for > it. > > On Sat, Jul 13, 2019 at 5:09 PM Samuel Wales wrote: > > would spaces work for you too? > > -- > The Kafka Pandemic > > What is misopathy? > > https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html > > The disease DOES progress. MANY people have died from it. And ANYBODY > can get it at any time. -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] [PATCH] ob-plantuml.el support for non-UML diagrams
Sounds great, is it merged now? Henrik Koschitzki writes: > Hello, > ob-plantuml encloses the body of PlantUML ( http://plantuml.com) diagram code > with @startuml/@enduml clauses. Recent versions of PlantUML support non-UML > diagrams > like gantt, mindmap and others that needs to be enclosed with > @startgantt/@endgantt and @startmindmap/@endmindmap clauses. > > I created a patch that only inserts @startuml and @enduml if the body does > not already starts with the string "@start". This patch allows the execution > of existing > UML diagrams without @startuml/@enduml as well as non-UML diagrams that > contain any @start-/@end- clause. > > Regards > > Henrik Koschitzki -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] [Feature proposal] Add :description function to org-link-parameters
I propose this feature too. Hope can add this. Ihor Radchenko writes: > Hi, > > Wondering if anyone is interested in adding a new org-link property to > customise generating the link description. > > For now, there is global org-link-make-description-function, which is > shared among all the link types. If would be more convenient if the > description function can be set independently for different link types. > > I propose to use :description property in org-link-parameters. A sample > implementation working with current org version is below: > > #+begin_src emacs-lisp > (defun yant/org-make-link-description-function (link desk) > "Return description of the link LINK according to :description link > property. > Return DESK if :desk is not set." > (let ((fun (org-link-get-parameter (car (split-string link ":")) > :description))) > (if (functionp fun) > (funcall fun link desk) > desk))) > > (setq org-make-link-description-function > #'yant/org-make-link-description-function) > #+end_src > > Example usage: > > #+begin_src emacs-lisp > (defun org-id-link-desk (link desk) > "Description function for id: link." > (let ((id (cadr (split-string link ":" > (org-with-point-at (org-id-find id 'marker) > (s-replace "||" "/" (yant/task-fulltitle) > > (org-link-set-parameters "id" > :desk #'org-id-link-desk) > #+end_src > > Best, > Ihor -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] Feature Request: Use ~org-set-tags-command~ for ~%^g~ in capture
Samuel W. Flint writes: > Hello! > > Is there a way to use the ~org-set-tags-command~ function to complete > tags during capture? It currently uses whatever my normal completion > method is, but this means that I can't use the faster tag-selection > method that I'm used to otherwise. I'm looking for this method too. Have you found solution now? -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] Oas: a small addon to Org Mode to automatically close tasks with statistics
Interesting addon, I like this idea. :) I remember Org Mode has a similar option (can't figure out the option name). And also have some similar solution like this. Just they are depend on "task dependencies". I want to add some hooks on your code, but found this code is hard to read. I agree Adam's advice, better to use ~org-element~ API to do parsing. Andrea Giugliano writes: > Hi, > > I recently landed on this conversation: > https://lists.gnu.org/archive/html/emacs-orgmode/2010-03/msg00802.html > > Since I find myself quite often in a situation like the following: > > * TODO abc [3/3] > - [X] a > - [X] b > - [X] c > > I decided to dive more into Org's API, and I created this library [0] to > automatically moving that task to DONE. My library checks that when you > are in a situation like: > > * TODO abc [1/1] > - [X] a > > ** TODO b > > the parent task does not swap to DONE because there is still a sub-task > to complete. > > Tasks that have heading like > > * abc [0/1] > > or > > * TODO abc > > do NOT get updated, because I want this to work only for TODO that have > statistics. > > How could I propose this as an add-on of Org Mode? Do you think it is > worth the effort? > > Any feedback is very welcome to learn more :) > > Best, > > Andrea > > [0] https://github.com/ag91/org-active-statistics -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] Inserting a link when setting a property
Rob Duncan writes: > I'd like to be able to use C-c C-l (org-insert-link) to specify a link when > setting a property value with C-c C-x p (org-set-property) but that key > sequence > isn't recognized in that mode. What's the best way to set things up so this > works? I think you have to add an empty property (without value) at first, then manually move to that property link, and invoke command =[C-c C-l]= (~org-insert-link~). This what I do now. -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] [ANN] org-sidebar-tree: Sidebar tree-view buffer for outline navigation
This is really a helpful sidebar package. Thanks :) I like it very much. Hope can add an command to toggle it. I found I have to manually close it. Adam Porter writes: > Hi friends, > > I've published an easy-to-use version of a tool that I think Org has > long needed: a sidebar tree-view buffer for navigating outlines. > > https://github.com/alphapapa/org-sidebar#org-sidebar-tree > > There have been some similar, unpolished tools floating around, > including an answer I posted on Emacs.StackExchange several years ago. > And the org-panes package has been around even longer, but hasn't been > touched for 5 years, and it isn't on MELPA, so few people know about it. > > So I've put together org-sidebar-tree and released it as part of > org-sidebar, which makes it easy to use and customize. Here are some > screenshots: > > https://github.com/alphapapa/org-sidebar/raw/master/images/tree.gif > https://github.com/alphapapa/org-sidebar/raw/master/images/sidebar-with-tree.png > https://github.com/alphapapa/org-sidebar/raw/master/images/tree-and-item-sidebars.png > > It seems to work well, but I'm sure wider testing will reveal some > improvements to be made. I'd appreciate any feedback. > > Thanks, > Adam -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] noweb and :var statements
I wrote: > [..] > > Please try it with emacs -Q. Maybe your config is broken. After starting emacs -Q you will have to M-x customize-variable RET org-babel-load-languages and add Python as a loaded language.
Re: [O] noweb and :var statements
Ken Mankoff writes: > On 2019-10-06 at 21:52 +02, Sebastian Miele > wrote... >> I wrote: >> >>> [..] >>> >>> However, something like the following may suit your use case. (For the >>> header-args property see section 15.2 (Using Header Arguments) of the >>> manual.) >>> >>> * A Heading >>> :PROPERTIES: >>> :header-args: :var table=table_foo >>> :END: >>> >>> #+NAME: table_foo >>> | foo | >>> |-| >>> | 42 | >>> | 100 | >>> >>> #+NAME: import >>> #+BEGIN_SRC python >>> import numpy as np >>> table = np.array(table).astype(np.float).flatten() >>> #+END_SRC >>> >>> #+BEGIN_SRC python :noweb yes :tangle import_noweb.py >>> <> >>> #+END_SRC >> >> Just the following works too, of course: >> >> #+NAME: table_foo >> | foo | >> |-| >> | 42 | >> | 100 | >> >> #+NAME: import >> #+BEGIN_SRC python >> import numpy as np >> table = np.array(table).astype(np.float).flatten() >> #+END_SRC >> >> #+BEGIN_SRC python :noweb yes :var table=table_foo :tangle import_noweb.py >> <> >> #+END_SRC > > The result of tangling this is "import_noweb.py" contains: > > import numpy as np > table = np.array(table).astype(np.float).flatten() > > And I'd like it to somewhere include the line: > table = [42,100] > or something similar. I don't have the table data in the tangled code. Strange. On my system, typing C-c C-v t (org-babel-tangle) in an Org file with the above mentioned contents does yield a file import_noweb.py with the following contents: table=[[42], [100]] import numpy as np table = np.array(table).astype(np.float).flatten() Please try it with emacs -Q. Maybe your config is broken.
Re: [O] noweb and :var statements
Ken Mankoff writes: > Hi Sebastian, > > I'm not getting the results I expect from your MWE either. Perhaps I > gave too much code and asked X when what I really want is Y. I think > I've distilled it to this: > > What is the most elegant Org way to get a table into a Python array? I do not know whether it is the most elegant way, but the following works, and probably is at least close to shortes possible way: #+NAME: table_foo | foo | |-| | 42 | | 100 | #+BEGIN_SRC python :var table=table_foo :tangle table.py #+END_SRC After tangling, table.py contains "table=[[42], [100]]". Did you know that you can have several source code blocks tangling to the same file? Maybe you do not really need noweb stuff at all. If you add a second block, e.g. #+BEGIN_SRC python :tangle table.py mangle_table #+END_SRC then, after tangling, table.py contains "table=[[42], [100]]" and "mangle_table". > I can code it directly: > > #+BEGIN_SRC python > <> > print(foo) > #+END_SRC > > > And now I can hide <> in a section at the bottom of the > document. If it looks like this, everything works: > > #+NAME: setup > #+BEGIN_SRC python > foo = np.array([42,43,44]) > #+END_SRC > > But is there a more elegant method? Can I get the same behavior if the > data I want is in an Org table rather than hard-coded directly in > Python? This use-case is covered by what I wrote above. You can put the named Org table at the bottom of the file. Another note: You can tangle to different files from one Org file. You may e.g. add an additional source block: #+BEGIN_SRC python :tangle use_table.py include_table_py use_table #+END_SRC where include_table_py must be replaced by the Python way of saying: include the file table.py. (I do not know Python.) > Ideally, I'd like to have: > > #+NAME: setup > #+BEGIN_SRC python > <> > <> > #+END_SRC > > And a #+NAME: setup block that takes a :var table and sticks it in the > :var varname variable. I strongly suspect that you do not really need noweb stuff and still struggle to understand the very basics of tangling. > And then after calling <> be able to use variable "foo" and > "bar" that are generated from column or 2D Org tables elsewhere in the > document. Can I do this in Org? > > Thanks, > > -k.
Re: [O] noweb and :var statements
On 2019-10-06 at 21:52 +02, Sebastian Miele wrote... > I wrote: > >> [..] >> >> However, something like the following may suit your use case. (For the >> header-args property see section 15.2 (Using Header Arguments) of the >> manual.) >> >> * A Heading >> :PROPERTIES: >> :header-args: :var table=table_foo >> :END: >> >> #+NAME: table_foo >> | foo | >> |-| >> | 42 | >> | 100 | >> >> #+NAME: import >> #+BEGIN_SRC python >> import numpy as np >> table = np.array(table).astype(np.float).flatten() >> #+END_SRC >> >> #+BEGIN_SRC python :noweb yes :tangle import_noweb.py >> <> >> #+END_SRC > > Just the following works too, of course: > > #+NAME: table_foo > | foo | > |-| > | 42 | > | 100 | > > #+NAME: import > #+BEGIN_SRC python > import numpy as np > table = np.array(table).astype(np.float).flatten() > #+END_SRC > > #+BEGIN_SRC python :noweb yes :var table=table_foo :tangle import_noweb.py > <> > #+END_SRC The result of tangling this is "import_noweb.py" contains: import numpy as np table = np.array(table).astype(np.float).flatten() And I'd like it to somewhere include the line: table = [42,100] or something similar. I don't have the table data in the tangled code. -k.
Re: [O] noweb and :var statements
Hi Sebastian, I'm not getting the results I expect from your MWE either. Perhaps I gave too much code and asked X when what I really want is Y. I think I've distilled it to this: What is the most elegant Org way to get a table into a Python array? I can code it directly: #+BEGIN_SRC python <> print(foo) #+END_SRC And now I can hide <> in a section at the bottom of the document. If it looks like this, everything works: #+NAME: setup #+BEGIN_SRC python foo = np.array([42,43,44]) #+END_SRC But is there a more elegant method? Can I get the same behavior if the data I want is in an Org table rather than hard-coded directly in Python? Ideally, I'd like to have: #+NAME: setup #+BEGIN_SRC python <> <> #+END_SRC And a #+NAME: setup block that takes a :var table and sticks it in the :var varname variable. And then after calling <> be able to use variable "foo" and "bar" that are generated from column or 2D Org tables elsewhere in the document. Can I do this in Org? Thanks, -k.
Re: [O] noweb and :var statements
I wrote: > [..] > > However, something like the following may suit your use case. (For the > header-args property see section 15.2 (Using Header Arguments) of the > manual.) > > * A Heading > :PROPERTIES: > :header-args: :var table=table_foo > :END: > > #+NAME: table_foo > | foo | > |-| > | 42 | > | 100 | > > #+NAME: import > #+BEGIN_SRC python > import numpy as np > table = np.array(table).astype(np.float).flatten() > #+END_SRC > > #+BEGIN_SRC python :noweb yes :tangle import_noweb.py > <> > #+END_SRC Just the following works too, of course: #+NAME: table_foo | foo | |-| | 42 | | 100 | #+NAME: import #+BEGIN_SRC python import numpy as np table = np.array(table).astype(np.float).flatten() #+END_SRC #+BEGIN_SRC python :noweb yes :var table=table_foo :tangle import_noweb.py <> #+END_SRC
Re: [O] noweb and :var statements
Hi Ken! Ken Mankoff writes: > I'm having with noweb and variables. Can someone explain what I'm > doing wrong? For example, if I have this table: > > #+NAME: table_foo > | foo | > |-| > | 42 | > | 100 | > > And I want to import it into Python and use it, I can do that like this: > > #+NAME: import > #+BEGIN_SRC python :var table=table_foo :session foo > import numpy as np > table = np.array(table).astype(np.float).flatten() > #+END_SRC > > Eval of this block works, and if I tangle it, I see: > >> table=[[42], [100]] >> import numpy as np >> table = np.array(table).astype(np.float).flatten() > > But if I want to use that block elsewhere via noweb, it doesn't seem to work: > > #+BEGIN_SRC python :results output drawer :noweb yes :session foo :tangle > import_noweb.py > <> > #+END_SRC > > The code runs and in a clean *foo* session I do have my table > variable, but I *also* get an error. The buffer contains the text at > the bottom of this message, and the tangled code in import_noweb.py is > only "nil". > > How can I 1) run noweb blocks with variables and 2) tangle noweb > blocks with variables (i.e. tangle tables into source files). Section 15.10 (Noweb Reference Syntax) of the manual says that e.g. <> (a noweb reference with parentheses) executes the NAMEd block with the specified binding and inserts the results of the execution during tangling. That probably is why the table variable is there in the session. But the results of executing <> at that place were not what was intended. If it were something like #+NAME: import #+BEGIN_SRC python :var table=table_foo :results output import numpy as np table = np.array(table).astype(np.float).flatten() CODE #+END_SRC where CODE is replaced by some Python code that prints the wanted Python code, it would work. (Note the omission of the :session and the addition of :results output. See section 15.5 (Results of Evaluation) of the manual for the reasons.) As far as I understand the manual there may be no way to directly attain what you are trying. However, something like the following may suit your use case. (For the header-args property see section 15.2 (Using Header Arguments) of the manual.) * A Heading :PROPERTIES: :header-args: :var table=table_foo :END: #+NAME: table_foo | foo | |-| | 42 | | 100 | #+NAME: import #+BEGIN_SRC python import numpy as np table = np.array(table).astype(np.float).flatten() #+END_SRC #+BEGIN_SRC python :noweb yes :tangle import_noweb.py <> #+END_SRC Best wishes Sebastian
Re: [O] helm problem on MELPA ?
The helm problem on MELPA is solved.. Many thanks for this quick and good work ! Best wishes, Jo. Le dim. 6 oct. 2019 à 19:30, Joseph Vidal-Rosset a écrit : > > Hi everybody, > > After an upgrade, I meet a problem that is probably a helm problem on > MELPA. Here are the warnings: > > Error (use-package): Cannot load helm-bibtex > Error (use-package): Cannot load helm-projectile > Error (use-package): org-ref/:catch: Cannot open load file: Aucun > fichier ou dossier de ce type, helm-config > Error (use-package): scimax-org/:init: Cannot open load file: Aucun > fichier ou dossier de ce type, helm-config > Error (use-package): scimax-journal/:catch: Cannot open load file: > Aucun fichier ou dossier de ce type, helm-config > > The result is almost nothing work in my emacs, the agenda does not > load, and so on. :( > > That is the first time that I see such a problem. > > Best wishes, > > Jo. > > PS: I'm using John Kitchin scimax, and John just told me that he saw > the same thing.
[O] helm problem on MELPA ?
Hi everybody, After an upgrade, I meet a problem that is probably a helm problem on MELPA. Here are the warnings: Error (use-package): Cannot load helm-bibtex Error (use-package): Cannot load helm-projectile Error (use-package): org-ref/:catch: Cannot open load file: Aucun fichier ou dossier de ce type, helm-config Error (use-package): scimax-org/:init: Cannot open load file: Aucun fichier ou dossier de ce type, helm-config Error (use-package): scimax-journal/:catch: Cannot open load file: Aucun fichier ou dossier de ce type, helm-config The result is almost nothing work in my emacs, the agenda does not load, and so on. :( That is the first time that I see such a problem. Best wishes, Jo. PS: I'm using John Kitchin scimax, and John just told me that he saw the same thing.
[O] noweb and :var statements
Hi Org list, I'm having with noweb and variables. Can someone explain what I'm doing wrong? For example, if I have this table: #+NAME: table_foo | foo | |-| | 42 | | 100 | And I want to import it into Python and use it, I can do that like this: #+NAME: import #+BEGIN_SRC python :var table=table_foo :session foo import numpy as np table = np.array(table).astype(np.float).flatten() #+END_SRC Eval of this block works, and if I tangle it, I see: > table=[[42], [100]] > import numpy as np > table = np.array(table).astype(np.float).flatten() But if I want to use that block elsewhere via noweb, it doesn't seem to work: #+BEGIN_SRC python :results output drawer :noweb yes :session foo :tangle import_noweb.py <> #+END_SRC The code runs and in a clean *foo* session I do have my table variable, but I *also* get an error. The buffer contains the text at the bottom of this message, and the tangled code in import_noweb.py is only "nil". How can I 1) run noweb blocks with variables and 2) tangle noweb blocks with variables (i.e. tangle tables into source files). Thanks, -k. table=[[42], [100]] Python 2.7.15+ (default, Jul 9 2019, 16:51:35) [GCC 7.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> python.el: native completion setup loaded >>> >>> import numpy as np table = np.array(table).astype(np.float).flatten() open('/tmp/babel-Mb4ojd/python-GEnZeZ', 'w').write(str(_)) 'org_babel_python_eoe' >>> Traceback (most recent call last): File "", line 1, in NameError: name '_' is not defined >>> >>> >>> 'org_babel_python_eoe' >>> >>> >>> >>> >>> 'org_babel_python_eoe' 'org_babel_python_eoe' >>>
[O] Handling of org-edit-src-content-indentation
Dear fellows! GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10) of 2019-08-29 Org mode version 9.2.6 (release_9.2.6-544-gd215c3 @ /home/w/borg/emacs/org/lisp/) The variable org-edit-src-content-indentation has a default value of 2. Buffer-local values for that variable currently are not respected when using org-edit-src-code. Buffer-local values for this variable are set in e.g. worg/.dir-locals.el. The bug can be fixed by changing org-edit-src-content-indentation into (with-current-buffer (marker-buffer org-src--beg-marker) org-edit-src-content-indentation) in the definition of org-src--contents-for-write-back. However, the general patterns in the org-src.el suggest, that something similar to (defvar-local org-src--preserve-indentation nil) (put 'org-src--preserve-indentation 'permanent-local t) should be introduced, set up, and used. But except following the pattern, I see no advantage in the latter approach, even two slight disadvantages. The first beeing that it uses more lines of code, and the second being so minor and opinionated that I don't mention it. Which route shall I take when preparing a patch? Best wishes Sebastian
Re: [O] [RFC] Replace lambda functions added to org-mode-hook with named funcs
I propose one vote for this too. This give user better understanding. Some times I check out the variable org-mode-hook's value for troubleshooting, the meaningful function names can help me read quickly. Phil Sainty writes: > On Fri, Oct 5, 2018, 6:42 AM Nicolas Goaziou wrote: >> Kaushal Modi writes: >> > I propose to replace such lamba functions with named functions. >> > Here's an example of diff on maint branch, after making one such change: >> > >> > -;; Remove overlays when changing major mode >> > -(add-hook 'org-mode-hook >> > - (lambda () (add-hook 'change-major-mode-hook >> > - 'org-show-block-all 'append 'local))) >> > +(defun org--unfold-all-blocks-on-major-mode-change () >> > + "Remove overlays when changing major mode." >> > + (add-hook 'change-major-mode-hook #'org-show-block-all 'append 'local)) >> > +(add-hook 'org-mode-hook #'org--unfold-all-blocks-on-major-mode-change) >> >> If that's a function added to `org-mode-hook', it is not useful to >> add "on major mode change". > > Certainly it's useful. Or at least in general it's a common *pattern* > for a major mode to add a function to `change-major-mode-hook' so that > if the user changes from that major mode to some other major mode, the > function will be called and can put the buffer into a sensible state > before the replacement mode function is called. > > The only curious thing about it to me is that this code is being run > via `org-mode-hook' rather than in the `org-mode' body; but maybe > there's some reason for that. > > > Regarding the general issue: > > Grep shows me all of the following instances in the master branch > (commit d215c3a8c0b4c027), where a lambda is added to a hook variable > (a few of them in the form of commented suggestions to the user). > > It's never a good idea; all of these should be changed to use named > functions, IMO. > > > -Phil > > > -*- grep -*- > ./ob-core.el:1429:(add-hook 'org-mode-hook > ./ob-haskell.el:66: (add-hook 'inferior-haskell-hook > ./ol-w3m.el:171:(add-hook > ./ol-w3m.el:176:(add-hook > ./org-agenda.el:2246: (add-hook 'filter-buffer-substring-functions > ./org-agenda.el:2935: (add-hook > ./org-attach.el:697:;; (add-hook > ./org-compat.el:813: (add-hook 'imenu-after-jump-hook > ./org-compat.el:817: (add-hook 'org-mode-hook > ./org-compat.el:880: (add-hook 'speedbar-visiting-tag-hook > ./org-crypt.el:144: (add-hook 'auto-save-hook > ./org-crypt.el:267: (add-hook > ./org-ctags.el:196:(add-hook 'org-mode-hook > ./org-ctags.el:59:;;(add-hook 'org-mode-hook > ./org-indent.el:188: (add-hook 'filter-buffer-substring-functions > ./org-mouse.el:1085:(add-hook 'org-agenda-mode-hook > ./org-mouse.el:856:(add-hook 'org-mode-hook > ./org-src.el:745: (add-hook \\='org-src-mode-hook > ./org.el:15697: (add-hook 'after-save-hook > ./org.el:18978:(add-hook 'occur-mode-find-occurrence-hook > ./org.el:21221:(add-hook 'org-mode-hook ;remove overlays when changing > major > mode > ./org.el:2916: (add-hook \\='org-capture-mode-hook -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] [RFC] Document level property drawer
Hi Matt, Thanks for your comment! I can assure you that you need not worry about the propsed patch here in terms of your workflow. This is in no way a hasty, sloppy work. Care has been taken when developing it to not break anything existing. I hear your concerns on the larger topic of keywords though. But that's not something that is changing in this patch. Some more comments below. > I'd like to just quickly chime in in support of Adam's caution on this > issue. I can absolutely see advantages to document level properties, I > have written many code fragments that rely on the use of keywords and > expect org filensyntax to be consistent with what actually exists. I > use these code fragments to hold together a somewhat fragile workflow > that allows me to use org in a work environment that is not especially > receptive to simple text documents. I have invested a lot of time in > making those systems run and sometimes even I don't entirely remember > what I did to make them possible. > > It would really, really suck to have those systems break. It would > take me a lot of time to track down the causes and change what I > needed to. VMs that currently pull in Emacs andnorg and my code would > stop working. Old versions of my files would no longer render > properly. My efforts to make my courses and other writings effectively > reproducible by others would be significantly set back. Etc. I think > these are the kinds of difficulties Adam means to describe. Again, caution is ofc taken. In no way does this patch change any of your existing properties. If something, it proposes a way for you to simplify your setup if you at any time in the future choose to do that. The patch that is applied is tested and no existing functionailty is changed. Ofc, if you have a critical flow I'd advice you to use the stable branch of Org mode and not rely on the master branch, since that branch from time to time will get bugs in it. Regards Gustav
[O] [ANN] org-ql 0.3 released
Hi friends, Version 0.3 of org-ql has been released. There are many changes, including a new helm-org-ql command and an alternative, non-sexp query syntax. - Changelog: https://github.com/alphapapa/org-ql#03 - helm-org-ql demo: https://github.com/alphapapa/org-ql/raw/master/images/helm-org-ql.gif Here are some examples of the new syntax (somewhere along the line, these lines will probably get mangled): | Sexp syntax | Non-sexp syntax | |-+-| | (todo) | todo: | | (todo "SOMEDAY")| todo:SOMEDAY | | (todo "SOMEDAY" "WAITING") | todo:SOMEDAY,WAITING | | (ts :on today) | ts:on=today | | (ts-active :from "2017-01-01" :to "2018-01-01") | ts-active:from=2017-01-01,to=2018-01-01 | | (clocked :on -1)| clocked:on=-1 | | (heading "quoted phrase" "word")| heading:"quoted phrase",word| | (and (tags "book" "books") (priority "A")) | tags:book,books priority:A | | (priority >= B) | priority:A,B | Please let me know if you have any problems or suggestions. Thanks.