all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Bad Blue Bull <ibmbull@yandex.ru>
Cc: "32281@debbugs.gnu.org" <32281@debbugs.gnu.org>
Subject: bug#32281: shr.el align support patch
Date: Mon, 06 Aug 2018 22:34:52 -0400	[thread overview]
Message-ID: <87a7pyykdv.fsf@gmail.com> (raw)
In-Reply-To: <4760541533603112@sas1-890ba5c2334a.qloud-c.yandex.net> (Bad Blue Bull's message of "Tue, 07 Aug 2018 03:51:52 +0300")

Bad Blue Bull <ibmbull@yandex.ru> writes:

>>  The first line of the doc string should not be longer than 78
>>  characters, and should be a complete sentence.
>
> I don't know what do you mean of "complete sentence", docs say it must
> start with a capital letter and end with a period.  First sentence now
> fills 2 lines I know it's not good for apropos, I can edit it again if
> needed.

Yeah, that's all we mean there, the whole sentence (i.e., from capital
letter to period) needs to fit on the first line.

>>  Why did you decide to use u+2028 and u+2029 for these purposes? Emacs
>>  doesn't yet support these characters as Unicode intended, so using
>>  them might have unexpected effects, and might produce different effect
>>  if we start supporting them in the future.
>
> I need to use a character to mark places where lines must be split
> (specified by <br> tags and end of list items), also a character to
> mark end of a paragraph to be filled (a mark can be used for this
> purpose but docs warn against it).
[also quoting clarification from following message]
> This phrase looks confusing, sorry, I meant push-mark can be used for
> this purpose but it's no good.

By "docs warn against it", were you referring to

    Novice Emacs Lisp programmers often try to use the mark for the wrong
    purposes.  See the documentation of ‘set-mark’ for more information.

That's just about using that particular function for non-interactive use
cases.  If it does makes sense to use a mark for this, just don't use
push-mark or set-mark, but rather copy-mark and save the resulting mark
object to a local variable.

> +  (save-excursion
> +   (let ((line-begin) (paragraph-end))
> +	 (forward-paragraph)
> +	 (insert "\x2029") ; use \x2029 (unicode paragraph separator) to mark end
> +					   ; of a paragraph
> +	 (backward-paragraph)
> +	 (setq line-begin (point))
> +	 (while (not paragraph-end)
> +			(re-search-forward bre-regexp)
> +			(if (equal (match-string 0) "\x2029") (setq paragraph-end t))
> +										; end of paragraph reached
> +			(if (or bre-del paragraph-end) (replace-match ""))
> +			(unless (equal (char-after) ?\n) (insert "\n"))
> +										; I don't know why but two adjacent \n
> +										; leave an empty line after fill
> +			(fill-region-as-paragraph line-begin (- (point) 1)
> +			justify)
> +			(setq line-begin (point)))
> +	 (delete-char -1))))

Regarding the indentation, here's what I get after running indent-region
over the above code:

  (save-excursion
    (let ((line-begin) (paragraph-end))
      (forward-paragraph)
      (insert "\x2029") ; use \x2029 (unicode paragraph separator) to mark end
                                        ; of a paragraph
      (backward-paragraph)
      (setq line-begin (point))
      (while (not paragraph-end)
        (re-search-forward bre-regexp)
        (if (equal (match-string 0) "\x2029") (setq paragraph-end t))
                                        ; end of paragraph reached
        (if (or bre-del paragraph-end) (replace-match ""))
        (unless (equal (char-after) ?\n) (insert "\n"))
                                        ; I don't know why but two adjacent \n
                                        ; leave an empty line after fill
        (fill-region-as-paragraph line-begin (- (point) 1)
                                  justify)
        (setq line-begin (point)))
      (delete-char -1)))

Notice especially the difference in the while loop body.  You mentioned
lisp-body-indent, but that only affects indentation increase after a
defun line.  I do see that your indentation after the let seems to be
based on 4-space tabs, but Emacs uses 8-space tabs.  If you could set
indent-tabs-mode to nil (which is what the .dir-locals in the git
repository does), that would take care of it regardless.





  parent reply	other threads:[~2018-08-07  2:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26 14:06 bug#32281: shr.el align support patch Bad Blue Bull
2018-08-06  2:52 ` Noam Postavsky
2018-08-06 15:13   ` Eli Zaretskii
2018-08-07  0:51     ` Bad Blue Bull
2018-08-07  0:59       ` Bad Blue Bull
2018-08-07  2:34       ` Noam Postavsky [this message]
2018-08-07 15:07       ` Eli Zaretskii
2018-08-07 16:54         ` Bad Blue Bull
2018-08-07 17:11           ` Bad Blue Bull
2018-08-07 17:19           ` Eli Zaretskii
2018-08-07 18:15             ` Bad Blue Bull
2018-08-07 18:15       ` Lars Ingebrigtsen
2018-08-07 19:56         ` Bad Blue Bull
2018-08-10  0:12           ` Noam Postavsky
2018-08-06 17:36 ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a7pyykdv.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=32281@debbugs.gnu.org \
    --cc=ibmbull@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.