QBobWatson / poporg

Emacs programming tool for editing strings or comments in Org mode or any other text mode
GNU General Public License v3.0
91 stars 9 forks source link

Different filling of an Emacs-lisp docstring #7

Closed DamienCassou closed 3 years ago

DamienCassou commented 5 years ago

If I go to line 113 of this file and type M-x lisp-fill-paragraph, nothing changes. But if I open poporg's buffer and type M-x org-fill-paragraph, then the word back (first word of line 114) comes at the end of line 113. The fill-column in both buffers is 70.

QBobWatson commented 5 years ago

When you run fill-paragraph in an emacs-lisp buffer, it fills to emacs-lisp-docstring-fill-column, which in your case is probably 65. (I believe it does this whether you're filling a docstring or code -- but not comments.)

It would be nice if poporg set fill-column to emacs-lisp-docstring-fill-column if you're editing an emacs-lisp buffer. This can be accomplished by adding a hook to poporg-edit-hook. Here's how you can tell what mode your original buffer is in:

(defun my:editing-lisp-string-p ()
  "Return true if this is a poporg edit buffer from a lisp buffer."
  (let ((buf (poporg-orig-buffer)))
    (and buf (with-current-buffer buf
               (derived-mode-p 'emacs-lisp-mode)) t)))
DamienCassou commented 5 years ago

Joe Rabinoff notifications@github.com writes:

[…] It would be nice if poporg set fill-column to emacs-lisp-docstring-fill-column if you're editing an emacs-lisp buffer. This can be accomplished by adding a hook to poporg-edit-hook.

thank you for your answer. Are you suggesting that (1) poporg itself should do something similar or that (2) it is the responsibility of users to change their configuration? I think (1) makes more sense.

-- Damien Cassou http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill

QBobWatson commented 5 years ago

To me, this is a quirk of emacs-lisp-mode. If you do fill-region on a docstring in an emacs-lisp buffer, then it uses fill-column anyway, so the behavior isn't consistent even within the major mode. Which behavior should poporg replicate? I'd argue that the correct answer is to just set emacs-lisp-docstring-fill-column to fill-column.

That said, I could go either way on this -- you're always welcome to submit a pull request.