[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Paragraph styles in doc strings

From: Clément Pit--Claudel
Subject: Re: Paragraph styles in doc strings
Date: Wed, 1 Jun 2016 19:01:24 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

On 2016-05-16 16:53, Stefan Monnier wrote:
> If we ever want to refill docstrings automatically (ideally when
> displaying them), then we'll need some stronger hint than a newline.
> So I guess an empty line is not a bad idea, but I would indeed welcome
> some font-lock hack that make those empty lines shorter.

I'm not sure font-lock will work nicely for this. Blank lines are a multi-line 

On the other hand, this seems to work OK:

(defvar help-blank-line-height 0.5)
(defvar help-blank-line-regexp "\n\n+")

(with-current-buffer "*Help*"
  (let ((inhibit-read-only t))
      (goto-char (point-min))
      (while (re-search-forward help-blank-line-regexp nil t)
         (match-beginning 0) (match-end 0)
         'font-lock-face `(:height ,help-blank-line-height))))))

Of course, you could use that loop instead to add a font-lock-multiline 
property to the newlines, and then use this:

(with-current-buffer "*Help*"
  (font-lock-add-keywords nil '(("\n\n+" 0 `(face (:height 0.5))))))

But that sounds like more code for no added benefit. The simplest solution is 
probably to change the function that inserts the docstring to insert a string 
with the right properties applied.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]