Open odabrunz opened 11 years ago
On Sun, Oct 21, 2012 at 10:42 PM, Olaf Dabrunz notifications@github.comwrote:
This is a request for the "clean view" as in emacs' org-mode. As described on the org-mode mailing list, only the last star before each heading is shown:
- Top level headline
- Second level
- 3rd level some text
- 3rd level more text
- Another top level headline
Olaf --
VimOrganizer should already do this. There is a highlight group called 'Org_Star' that is applied to asterisk strings that begin lines, in which all asterisks except the last in the string receive the highlighting. Assigning this highlight group the same color as your background effectively makes them invisible, with the result that you see the "clean view".
Something like the statement below will make these initial asterisks invisible, of course depending on the color of your background.
:highlight Org_Star guifg=[color of background] ctermfg=[color of background]
The best thing to do would be to put it in the OrgCustomColors function in your vimrc file:
function OrgCustomColors() highlight Org_Star guifg=[color of background] ctermfg=[color of background] endfunction
You can also look at the help section :h vimorg-customizing-colors
Hope that helps,
Herb
Thanks for pointing me to this!
I have to admit that I did not yet look at a number of the highlights in OrgCustomColors(), including the Org_Star highlight, although I have copied the function from the _vimrc in the VimOrganizer package.
It worked, but it needed the change in syntax/org.vim from cbf351d, which is not yet in http://www.vim.org/scripts/script.php?script_id=3342. I am still using the vim.org version -- should I switch to the git master?
Maybe the Org_Star highlight should get a special mention in the vimorg help file. It was a bit too easy to overlook.
I like that I could get the hiding to work relatively easily in a vim that runs in a terminal. emacs org-mode in a terminal "hides" the leading stars by using the default foreground color, which is very visible. Only in a GUI window the leading stars are really hidden. If I only knew more about font-lock I might get this to work in a terminal too, but it does not work out of the box.
Alas, I feel that there are a few things missing (some of them are already in emacs org-mode, as described in the "clean view" announcement (http://permalink.gmane.org/gmane.emacs.orgmode/22)), let me sum them up here:
hidestars
keyword#+STARTUP:
line as in emacs org-mode would be great.odd
keyword in a #+STARTUP:
line). Maybe this can be implemented in VimOrganizer as well (along with the org-convert-to-odd{,even}-levels
functions)?
If you would like to have some of these features (or some other solution), I could try to help implementing something (although I do not know that much about VimOrganizer internals yet, but I have done (mostly unreleased) patches to a number of other vim scripts and have programmed several larger (unreleased) vim scripts myself).
Thanks for the great work!
Olaf
On Mon, Oct 22, 2012 at 11:15 AM, Olaf Dabrunz notifications@github.comwrote:
It worked, but it needed the change in syntax/org.vim from cbf351dhttps://github.com/hsitz/VimOrganizer/commit/cbf351d, which is not yet in http://www.vim.org/scripts/script.php?script_id=3342. I am still using the vim.org version -- should I switch to the git master?
Yes, use the github master version.
Alas, I feel that there are a few things missing (some of them are already
in emacs org-mode, as described in the "clean view" announcement ( http://permalink.gmane.org/gmane.emacs.orgmode/22)), let me sum them up here:
1.
All the points you raise are good ones. Unfortunately, the "clean view" is mostly cosmetic issue and hasn't been requested by anyone else so it's pretty low on priority scale. I'm not spending a lot of time on this project and there are more pressing issues.
Regarding the issue with cursor highlighting in terminal vim, my guess is that it wouldn't be worth the effort of trying to find a fix.
Support for 'hidestars' would be good, but realistically most Org users either use clean view or they don't, they don't use it in some docs and not in others, so just having them set Org_Star highlight should work fine, even if not optimal.
Regarding odd numbers of stars: Yes, "clean view" in Org-mode has two parts: 1) hiding leading stars and 2) indenting of headings that lines up vertically. I had fooled around with system that used the equivalent of Org's 'odd' stars. The code is in current VimOrganizer but not in any way that exposes to users. If you want to switch your version to use "odd" stars then you can change one of the assignments at the top of org.vim in ftplugin directory. Around line 40 you will see this line:
let b:v.levelstars=1
To get "odd" star behavior change this to:
let b:v.levelstars=2
This will then start adding 2 stars for every level past level 1, with effect similar to Org's.
There is also a function in org.vim that would allow changing a document's status on the fly. That function is not exposed to the user, but if you want to look at it the code is here (as well as in your org.vim file):
function! s:StarLevelFromTo(from, to) let savecursor = getpos(".") set fdm=manual let b:v.levelstars = a:to ChangeSyn g/^+/call setline(line("."),substitute(getline(line(".")),'^+','' . \ repeat('_',(len(matchstr(getline(line(".")),'^+')) - 1) \ a:to / a:from),'')) set fdm=expr call setpos(".",save_cursor) endfunction
Calling 's:StarLevelFromTo(1,2)' would change current doc from regular stars to odd stars. Calling 's:StarLevelFromTo(2,1)' would convert an odd starred document back to regular starring. I haven't touched this in a long time, it was working bug-free, if I recall, a long time ago.
If you do use the odd star setup in VimOrganizer you would want to have settings in the document header that set up clean view in Emacs. These lines are not used in VimOrganizer, but Emacs would need them, e.g., if you were to export document to Emacs/Org-mode for printing.
-- Herb
On Mon, Oct 22, 2012 at 8:26 PM, Herbert Sitz hesitz@gmail.com wrote:
If you do use the odd star setup in VimOrganizer you would want to have settings in the document header that set up clean view in Emacs. These lines are not used in VimOrganizer, but Emacs would need them, e.g., if you were to export document to Emacs/Org-mode for printing.
Oh, I should also add that if you aren't using the "level dependent highlight" patch for Vim in the contrib directory of VimOrganizer download that you would probably want to recompile your Vim with that patch. This allows folded headings in Vim to have different colors depending on their level, i.e., makes fold colors like you get in Emacs/Orgmode. These changes are helpful to visually keeping levels straight in a way that's a little different from clean view, but, I think, more essential.
-- Herb
This is a request for the "clean view" as in emacs' org-mode. As described on the org-mode mailing list, only the last star before each heading is shown:
While vim could probably do something similar with concealed characters, VimOrganizer already uses the 'conceal' feature to implement hiding of URLs. As there is only one global
'conceallevel'
, the "clean view" cannot replace concealed chars with spaces while the URL hiding mode is set to completely remove these chars.I remember reading that you thought about implementing something akin to "clean view" by using headings with leading spaces in the org file, but that emacs org-mode does not support such a file format. I could not find that thread again, but IIRC Carsten Dominik said something to the effect that the leading stars are deeply entangled within org-mode's code.
My suggestion is to implement the "clean view" in VimOrganizer with leading spaces in the file anyway. This seems to be the only "clean" way to do this in vim. To preserve compatibility with emacs, this means another addition to the .emacs file is needed to convert such a file to the emacs org file format.
I am not sure how difficult it really is to change emacs' org-mode to accept such a "clean view" file format. After looking a bit into the code of emacs org-mode it seems it is still using outline-mode functions to match headings, but it sets specific
outline-regexp
andoutline-level
functions to use stars only (and to implement the tricks to get clean view working, such asorg-odd-levels
).There may be corner cases to catch, but I am not yet convinced that it is too difficult to implement.
The only problem I see is that people may use org files that contain lists with
'*'
as an item marker. These become difficult (or impossible?) to distinguish from "clean view" headings.Whatever can be done about this, I am not sure. But it may help to require a special
#+STARTUP: cleanview
line in the file to turn on recognition of clean view headings. Users of this file format need to make sure that their non-heading lines do not start with spaces and then a star.