From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#13949: 24.4.1; `fill-paragraph' should not always put the buffer as modified Date: Sun, 27 Mar 2016 09:44:55 +0200 Message-ID: <56F78F77.8000008@easy-emacs.de> References: <56F12360.5030301@ro.ru> <83y49a4hga.fsf@gnu.org> <56F1837D.4060300@ro.ru> <83io0e4b5r.fsf@gnu.org> <56F19203.5040501@ro.ru> <87a8lkd2bc.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1459064664 22160 80.91.229.3 (27 Mar 2016 07:44:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Mar 2016 07:44:24 +0000 (UTC) To: 13949@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 27 09:44:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ak5Mp-0005ew-SJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Mar 2016 09:44:12 +0200 Original-Received: from localhost ([::1]:35037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Mo-0005UX-Bb for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Mar 2016 03:44:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Mk-0005U5-Vm for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:44:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ak5Mg-0004A8-0O for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:44:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Mf-0004A4-TJ for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:44:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ak5Mf-0007sv-Ol for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Mar 2016 07:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13949 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145906460330255 (code B ref -1); Sun, 27 Mar 2016 07:44:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Mar 2016 07:43:23 +0000 Original-Received: from localhost ([127.0.0.1]:39124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ak5M2-0007rv-Tv for submit@debbugs.gnu.org; Sun, 27 Mar 2016 03:43:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ak5M1-0007rh-LF for submit@debbugs.gnu.org; Sun, 27 Mar 2016 03:43:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ak5Lv-00044r-KH for submit@debbugs.gnu.org; Sun, 27 Mar 2016 03:43:16 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Lv-00044n-Hc for submit@debbugs.gnu.org; Sun, 27 Mar 2016 03:43:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Lu-0005LS-FE for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:43:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ak5Lp-00043v-FV for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:43:14 -0400 Original-Received: from mout.kundenserver.de ([217.72.192.73]:64848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ak5Lp-00043p-6f for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2016 03:43:09 -0400 Original-Received: from [192.168.178.35] ([77.12.53.144]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MAMbS-1acxY80OWA-00BcAB for ; Sun, 27 Mar 2016 09:43:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Icedove/38.5.0 In-Reply-To: <87a8lkd2bc.fsf@wanadoo.es> X-Provags-ID: V03:K0:vbM5dAMhJQjgidX55cNnJxfu+NlOKSuA5ezM2eGKwO4Fhsw5fGe kz9ZBVR+Q8uD5xaVT2QM+QtBX45UAPspw8H2hzC/I2idZSDOFtMXU3PKYVFHc3tDryP9sf0 3OFG4xf9nm3Awyc0hnr/X64sZfjU7Wc3OjLHKFQgQNKBz5sTBF8sudNTWsHk3B87/guP0/M NvlB/cTpHV3h7ZYqpZaag== X-UI-Out-Filterresults: notjunk:1;V01:K0:Zaxt/0CozSs=:SEgsP9OGzPjT4A2jC+TeP1 rfq1W1KoixfpymMg1skBKR14ZEdXZbyWmRrpcoC1JxiYxO2t+M3DsiAuQV0K8CSsnH7WAPLhW czEBANmSE9vFpiazJPgJxlK7P6+y4noV6Zgp1M5uQwQbaMoS1BMGUcWlmkq9m8chDPgiH1ov2 Jb8qmpeuzsH+uHAcNWRG2Wn6GXJHuJ3vubyqXyvgSrgLPkRD4s4xc3YgFuw1Sve1iQXee13G+ xpdUn2xmycpmkI4zML+9G7lNe15CeYIJPAUh5i7YSrfw3bz5R+AilzdqFC6AF7JT9Hesyak1X SJS5QZc+q9xzPmaz1/gdGT+h0VYTlojfKSZ6UwXeESf9Xb8H9qqirRqoAesSLTz6rikfUlAWe ucre7fbws1JwFLd7e4TROazbU3DeUIVbFPuIV8zTuxrEZP8X8F9vN4Mj6LcQX8HEjc2wZHafG 9vJCFUwnJ2LpNM9q6w/9wlCr71Fr/azK16M5guW1jIZ+UjJhXbdBcxGp1Tzgt5uyyJWD4tR9T CnDbXRDy1jiR7+EdcrG62kAemDqUtd/16Cve8uzSJpCjEKgrlsMeyn4tOLhgXOIOHx+hi4EgT FiDZY6l33YjvgAzo79lRrebdD+ktxaFaml2P3jXc5Zm7tH2J9Bmk3OJHQ/mi96TeXXxy0dF9I tMuNNi536S3gf+zy58ZKcGOCsWeKJ0ANLc3lKE3RpmTl6TdLRv5nMDK7dOiY4HyTAB148LEZs YIMyo9LlbLvQyHKW X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115547 Archived-At: On 27.03.2016 05:31, Óscar Fuentes wrote: > John Wiegley writes: > >> So we must ask ourselves: What will fixing this issue actually solve? We'd no >> longer modify timestamps when unnecessary, and the user wouldn't feel >> compelled to save at times when it is not needed. That is all I can think of. >> Therefore, this bug is truly a wishlist item. >> >> I've noticed over the past couple of decades that M-q always sets my modified >> flag. It never once occurred to me that this should be considered a problem. > Emacs thinks that the buffer is modified when actually it isn't, and > gives this false information to the user and to itself. So we can't no > longer rely on the modeline indicator to know if the file was modified. > > Some features and packages (M-x compile, magit) ask the user when they > are invoked and there are buffers with unsaved changes. Saving a buffer > that doesn't change the file's contents (it just updates the file's > timestamp) may cause undesirable effects, like triggering a lengthy > build of a project. And so on. So it is not true that this "wishlist" > issue has no serious effects. Emacs is well below its usual level of > cleverness here. > > Computing hashes of the paragraph (or the whole buffer, if you wish) > before and after the operation and comparing them was suggested. Luckily > it is not complex at all. We already have `secure-hash' which can > operate on whole buffers or ranges. I attach a quick and dirty proof of > concept for fill-paragraph, which should be useful for evaluating > worst-case performance impact. This approach is not enough, as there are > other functions (such as lisp-fill-paragraph) that shows the same > problem. The low level functions which are used by *fill-paragraph are > the ones that should be patched. > > To Jaakov: I agree with you that this is a bug, and not a minor one at > that. However, the severity associated to this or any other report is > mostly irrelevant. Solving the problem depends on the existence of > someone who is willing to fix the issue. Almost all contributors here > work on what they decide to work on, and utterly ignore those labels. > > > diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el > index 100e2a2..9e1f430 100644 > --- a/lisp/textmodes/fill.el > +++ b/lisp/textmodes/fill.el > @@ -804,6 +804,7 @@ fill-paragraph > (interactive (progn > (barf-if-buffer-read-only) > (list (if current-prefix-arg 'full) t))) > + (setq h (if (buffer-modified-p) "" (secure-hash 'md5 (current-buffer)))) > (or > ;; 1. Fill the region if it is active when called interactively. > (and region transient-mark-mode mark-active > @@ -862,7 +863,10 @@ fill-paragraph > ;; fill-region. > (fill-region beg end justify) > (fill-region-as-paragraph beg end justify)))))) > - fill-pfx))) > + fill-pfx)) > + (when (and (not (string= h "")) > + (string= h (secure-hash 'md5 (current-buffer)))) > + (set-buffer-modified-p nil))) > > (declare-function comment-search-forward "newcomment" (limit &optional noerror)) > (declare-function comment-string-strip "newcomment" (str beforep afterp)) > > > Another solution would hash only the paragraph in question, re-format it in a temp buffer and replace original content only if changed.