From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#32281: shr.el align support patch Date: Mon, 06 Aug 2018 22:34:52 -0400 Message-ID: <87a7pyykdv.fsf@gmail.com> References: <6177421532613989@iva7-bd007c44f58e.qloud-c.yandex.net> <87wot4xl3g.fsf@gmail.com> <83bmafsf3l.fsf@gnu.org> <4760541533603112@sas1-890ba5c2334a.qloud-c.yandex.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1533609194 1682 195.159.176.226 (7 Aug 2018 02:33:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2018 02:33:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: "32281@debbugs.gnu.org" <32281@debbugs.gnu.org> To: Bad Blue Bull Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 04:33:10 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmro3-0000KJ-40 for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2018 04:33:07 +0200 Original-Received: from localhost ([::1]:37032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmrq9-0001ZX-Jy for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Aug 2018 22:35:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmrpz-0001Wi-O3 for bug-gnu-emacs@gnu.org; Mon, 06 Aug 2018 22:35:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmrpu-00014C-Pr for bug-gnu-emacs@gnu.org; Mon, 06 Aug 2018 22:35:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38046) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmrpu-000144-Lq for bug-gnu-emacs@gnu.org; Mon, 06 Aug 2018 22:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fmrpu-0002wh-FB for bug-gnu-emacs@gnu.org; Mon, 06 Aug 2018 22:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Aug 2018 02:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32281 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32281-submit@debbugs.gnu.org id=B32281.153360930111312 (code B ref 32281); Tue, 07 Aug 2018 02:35:02 +0000 Original-Received: (at 32281) by debbugs.gnu.org; 7 Aug 2018 02:35:01 +0000 Original-Received: from localhost ([127.0.0.1]:43064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmrps-0002wO-Sa for submit@debbugs.gnu.org; Mon, 06 Aug 2018 22:35:01 -0400 Original-Received: from mail-io0-f174.google.com ([209.85.223.174]:46991) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmrpr-0002wA-JA for 32281@debbugs.gnu.org; Mon, 06 Aug 2018 22:35:00 -0400 Original-Received: by mail-io0-f174.google.com with SMTP id i18-v6so12743381ioj.13 for <32281@debbugs.gnu.org>; Mon, 06 Aug 2018 19:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=kCd1BlGbV5bhlRON6EzlHAti6Byz78I+YMjcSrWMcHg=; b=Xtj0EN0CsYjiEKEm98I1NuNI+Tn7QTN0CunwPVksBq6/qdw1Oh7H2EAs/XICssxlS3 wFT10rx1SjI8VVhMAEQDHdK9cFHveZnc5kth5ZR3NU8o6oy55r9wr1yuusGA6hOV0c1u WJylHIgrce+IWTTTEkUPpiW5rSBuHNqViYpPFA8NbJC21p6HhZMG0AkWiPuMGwL+uoXT +mmecUyDtVNU2nQ6Bk9lnEJEsvB6QoZZhBt2WIjcaK3va0tJ27qAXtL2Aw27CEutnSMR ZrtNK3wlTgZGJHQaSLyVGSckEAc7y/ZT25ayO6+8duptgosl2WJB+Pv0QqGXmcjPYjz+ q46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=kCd1BlGbV5bhlRON6EzlHAti6Byz78I+YMjcSrWMcHg=; b=HwabbOCtkHiVtlrmEVG+Ta+FdFBSzVm9pSQcZ1tVW6TKT+MypiyFF9ztrb70XPD68D ntcqGPU53FqR8jypl63bmH4NDD4R3Pt7kTslnRjBW9PI34U7scu646td3i34C8ztZC64 FIAyS7+jl1KJMxXW8LNDhEvB+vvxk7ml0YL7S4TsWgmh1kKjhDFu6g/1xsDl/KtEQYVK okWkl38zslS8kU33N9/Nsqv33hVjRQtba125OVNbI/EhS0BSizAZJdl4jVQKD1EHn1av d63ZAHw6DpY/fGxDt7yDX+t5qtWgIB1x9GsXjC5zAC6KoV4v/CU4LVGh8g4wzEfNA8QF WG6A== X-Gm-Message-State: AOUpUlH9f0y9Ty42FghQCaoxyDsmPly4xPjg3gxCVTKg2bGHigXT0Smo WdWLRRqxEDcOW2mpxwx7cULDVrIk X-Google-Smtp-Source: AA+uWPye1ffkn1QHxUTVqrlh+vBj94C4AahAbWsu4nc+lTspD3ENq+j+nHY+helTE6BiaUmryNX2oQ== X-Received: by 2002:a6b:7312:: with SMTP id e18-v6mr16885300ioh.57.1533609293901; Mon, 06 Aug 2018 19:34:53 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id d63-v6sm263517itd.33.2018.08.06.19.34.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 19:34:53 -0700 (PDT) In-Reply-To: <4760541533603112@sas1-890ba5c2334a.qloud-c.yandex.net> (Bad Blue Bull's message of "Tue, 07 Aug 2018 03:51:52 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149303 Archived-At: Bad Blue Bull 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
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 =E2=80=98set-mark=E2=80=99 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 e= nd > + ; 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.