Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
How to configure headings? #7
Comments
|
Have you tried putting: (setq outline-regexp (rx (one-or-more "="))
outline-heading-alist (thblt/mk-outline-heading-alist "" ?= ""))At the end of the function? |
thblt
commented
Sep 11, 2017
|
Sorry about the original issue, I guess I sent it after struggling with this for too long, and didn't even notice it included a call to Following your advice, I tried this (with the same (defun init-literate-haskell ()
(interactive)
(literate-haskell-mode)
(setq outline-regexp (rx (one-or-more "="))
outline-heading-alist '(("=" . 1)
("==" . 2)
("===" . 3)
("====" . 4)
("=====" . 5)
("======" . 6)
("=======" . 7)
("========" . 8)))
(outline-minor-mode -1) ;; "Aggressively" reset the mode
(outline-minor-mode)
(outshine-hook-function)
(setq outline-regexp (rx (one-or-more "="))
outline-heading-alist '(("=" . 1)
("==" . 2)
("===" . 3)
("====" . 4)
("=====" . 5)
("======" . 6)
("=======" . 7)
("========" . 8))))
Backtrace 1
Backtrace 2
|
|
I know little about Haskell and nothing about Literate Haskell. From what I could quickly glean, it uses the regular Emacs haskell-mode. Is there specific support for Literate Haskell in haskell-mode? If so, it should redefine the appropriate variables related to comment syntax, and I think Outshine should pick up on that. If not, then I think Outshine will continue to use the non-Literate comment syntax. So I can think of two approaches you can try:
Basically, AFAIK, if the major-mode correctly supports comment syntax, Outshine will too. So if you can, add support in the major-mode, and then lots of other things in Emacs will benefit from it. |
thblt
commented
Sep 11, 2017
|
Literate Haskell is just regular Haskell + native compiler support for literate programming. Basically, ghc compiling a regular \section{Say Hello!}
This is a Hello World in Haskell. This line is not valid Haskell,
but it doesn't have to be: it's treated by the compiler as a comment.
First, we declare the type of \texttt{main} (this is optional):
\begin{code}
main :: IO ()
\end{code}
Then we provide an implementation
\begin{code}
main = putStrLn "Hello, world!"
\end{code}Or with a Markdown-like syntax = Say Hello!
This is a Hello World in Haskell. This line is not valid Haskell,
but it doesn't have to be: it's treated by the compiler as a comment.
First, we declare the type of `main` (this is optional):
> main :: IO ()
Then we provide an implementation
> main = putStrLn "Hello, world!"Both these are strict equivalents of, in regular Haskell with outline headings: -- * Say Hello!
-- This is a Hello World in Haskell. This line is not valid Haskell, but it doesn't have to be: it's treated by the compiler as a comment.
-- First, we declare the type of `main` (this is optional):
main :: IO ()
-- Then we provide an implementation
main = putStrLn "Hello, world!"
I'll try that, and will submit a PR if I'm any successful. My first idea would be to update the function to introduce a new variable associating major modes with a function to define the delimiters, so edge cases like literate programming modes (or haskell-mode itself, which doesn't work out of the box), could be successfully handled without, hopefully, too much overhead. What do you think? |
Yeah, that explains it. Outshine expects headings to be comments, so if they aren't comments in literate mode...
I'm not sure if you mean to map every major mode to a function or to allow the default to be overridden. Maintaining a mapping wouldn't be good, because it would have to be kept up-to-date, and it wouldn't make use of the built-in Emacs facilities like it does now. But providing a way to override the functions for modes that require it would be great. Of course, since it's a hook function, we can't pass args to it nor bind special variables around it (well, if we call it manually we can, but not if we add it to a hook). So I guess a customizable mapping allowing the defaults to be overridden by major-mode would be good. Or maybe the mapping should just disable the resetting of the
So non-literate haskell-mode doesn't work with Outshine by default? If so, that seems like a bug. Maybe that should be fixed first. And if that doesn't fix literate-haskell-mode, it would be good to see if there are any changes that need to be made to literate-haskell-mode first. I'm guessing that the commented-by-default style just isn't compatible with outline-minor-mode and/or Outshine by default, because Emacs isn't designed to work that way. Well, I thought of several things as I was writing, so I hope all that made sense. :) Thanks. |
thblt
commented
Sep 12, 2017
I was thinking of an override map only, since the default works on most cases. Something like
It's not a bug, just a documented edge case: Haskell needs the trailing space of |
thblt
commented
Sep 12, 2017
|
(I think the requirement for the trailing space to be present comes from the need to avoid reducing the range of valid function names: Haskell functions names don't have to include alphanumeric characters,, so someone may want a function called, eg, |
thblt
commented
Sep 12, 2017
|
On a related note, I'm beginning to suspect the original issue lies in outline-minor-mode, and maybe not Outshine. I'll investigate this and report back; maybe I underestimated the font lock issue as a symptom of something nastier. |
thblt commentedSep 10, 2017
I'm sorry if the answer to this question is obvious, but I'm completely stuck trying to make Outshine use my headings definition instead of the ones it computes. From
emacs -qin a Literate Haskell buffer, I'm trying this:This works perfectly well if I comment out
outshine-hook-function(except for font-locking which for some reason doesn't work with just Outline), but when calling the hook (or actually hooking it as documented, I just call it from the function for convenience), the heading delimiters seem to be computed from Outshine, and are completely wrong (eg, it makes-- *the level 1 delimiter, which is meaningless in Literate Haskell)Thanks!