From unknown Tue Aug 19 12:51:15 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#28390 <28390@debbugs.gnu.org> To: bug#28390 <28390@debbugs.gnu.org> Subject: Status: 26.0.50; overlays-at actually sorts by increating priority Reply-To: bug#28390 <28390@debbugs.gnu.org> Date: Tue, 19 Aug 2025 19:51:15 +0000 retitle 28390 26.0.50; overlays-at actually sorts by increating priority reassign 28390 emacs submitter 28390 joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) severity 28390 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 07 18:21:44 2017 Received: (at submit) by debbugs.gnu.org; 7 Sep 2017 22:21:45 +0000 Received: from localhost ([127.0.0.1]:54837 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq5BA-0000hA-CS for submit@debbugs.gnu.org; Thu, 07 Sep 2017 18:21:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq5B8-0000gu-7N for submit@debbugs.gnu.org; Thu, 07 Sep 2017 18:21:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq5Ax-0001QO-B6 for submit@debbugs.gnu.org; Thu, 07 Sep 2017 18:21:36 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dq5Ax-0001QH-6T for submit@debbugs.gnu.org; Thu, 07 Sep 2017 18:21:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq5Ar-0007OS-Ha for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 18:21:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq5Am-0001GX-7X for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 18:21:25 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:36378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq5Al-0001F3-Tb for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 18:21:20 -0400 Received: by mail-wm0-x235.google.com with SMTP id i189so4121562wmf.1 for ; Thu, 07 Sep 2017 15:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9uM/qBDbmiXFGUzHkUVu3OCJxaPlY11LcmZYolNFXT8=; b=dR3wR+/ukjRhLV5XNxXr+m+jGxtSRUOUIKNDc66Sp+bJghizYL5cE7CDxsr+MXqaO+ FozVk+KHBx8PWxf9LCPT6R65dJzZF6N12TYKj8lOsx0I5eqtl9MdSToiebRRLfsHqu6C Ht5mlikZl/5KOf3P+p9R2cQvYyu3SUFpUaXrQ6QoyYPljx8APxdsJZs4dC0+ZpmljMMf Fd5jgAWpmB2r5asuM+gJ6l2xGaSPVL9/BONA6vOFciRk0QugfXZiGYKvhMuTMLewcZKx qHHCUKCinOgKsjJHGR23RwqtlCWwWXK+ocwxhu81EZ/wDSJVmSvIKne1ph7fY6zeyPEq FPMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9uM/qBDbmiXFGUzHkUVu3OCJxaPlY11LcmZYolNFXT8=; b=BSiugFKkD66pvTfsiTzR9h0d/fr5Ivc7pXzbUHJpQflpNiRmTjsPNctrvBCVK/2NUW 083QoGtxtDTvZQwXY2bDRa8O3Gic8hD6e66fMqSlaIAt4MqKK/fI5hie68TcCnJLS/cv KPpVHBkmSrLHVVRM1emxu+lfJv7TA7yUmyZlmLmr+URWKwoGlKVU2ohlt/e7hXtA1VMb 15cGdXMM65hzT3J7EZ7j7tkpOBjs8GR6flCpZcvQl2yFlL5q1dtLB+kKUx14Pq2orJ+0 0Al6hPi8qa31qdHO9yaBstno8mNEEJ1PM7bpV8kUwNjOlyG0pBvZR/hU+GymoRsCZAkI LJXQ== X-Gm-Message-State: AHPjjUi3pbyRI88ZmEFB8p/PArq9S6CgBw38RXZ2k5Tbmu4XRYNMmNtB +1kpe6drcs3oAA== X-Google-Smtp-Source: AOwi7QA2FJdGe/u6AlAfVRuiD5FvgOi7SjjjOC0+HlZSJZS77ya7UY7kRDMkq4s5gLIg8Z7sdsZatQ== X-Received: by 10.28.87.147 with SMTP id l141mr249996wmb.144.1504822877534; Thu, 07 Sep 2017 15:21:17 -0700 (PDT) Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id k52sm470786wrf.62.2017.09.07.15.21.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 15:21:16 -0700 (PDT) From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) To: bug-gnu-emacs@gnu.org, monnier@iro.umontreal.ca Subject: 26.0.50; overlays-at actually sorts by increating priority Date: Thu, 07 Sep 2017 23:21:15 +0100 Message-ID: <871snijgkk.fsf@lolita> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hi Stefan, maintainters I believe I found a rather easy glitch in the doc of overlays-at. It says if SORTED in non-nil it sorts overlays by "decreasing" priority, but actually the reverse is true. Line 3234 of buffer.c seems to confirm this: /* Sort the overlays into the proper order: increasing priority. */ and compare_overlays passed to qsort() as well: return s1->priority < s2->priority ? -1 : 1; I also did this test: (progn (mapc #'delete-overlay (overlays-in (point-min) (point-max))) (dotimes (i 4) (overlay-put (make-overlay 20 30) 'priority i)) (mapcar (lambda (ov) (overlay-get ov 'priority)) (overlays-at 20 t))) this returns (0 1 2 3) This is a 3-year-old docbug, so I'm suspicious I might be missing something. Anyway here's a docpatch. Jo=C3=A3o diff --git a/src/buffer.c b/src/buffer.c index 2d508f35cf..14722f7c17 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4151,7 +4151,7 @@ OVERLAY. */) DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0, doc: /* Return a list of the overlays that contain the character at= POS. -If SORTED is non-nil, then sort them by decreasing priority. */) +If SORTED is non-nil, then sort them by increasing priority. */) (Lisp_Object pos, Lisp_Object sorted) { ptrdiff_t len, noverlays; diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 2ed848adf3..181b003501 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -1806,7 +1806,7 @@ Finding Overlays @defun overlays-at pos &optional sorted This function returns a list of all the overlays that cover the character = at position @var{pos} in the current buffer. If @var{sorted} is non-@code{ni= l}, -the list is in decreasing order of priority, otherwise it is in no particu= lar +the list is in increasing order of priority, otherwise it is in no particu= lar order. An overlay contains position @var{pos} if it begins at or before @var{pos}, and ends after @var{pos}. In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll b= ars) of 2017-08-24 built on lolita Repository revision: 5c048f5b327bbcd93d69c332a6c51ab139cd8071 Windowing system distributor 'The X.Org Foundation', version 11.0.11903000 System Description: Ubuntu 17.04 Recent messages: Undo! Saving file /home/capitaomorte/Source/Emacs/emacs/src/buffer.c... Wrote /home/capitaomorte/Source/Emacs/emacs/src/buffer.c Undo! Saving file /home/capitaomorte/Source/Emacs/emacs/src/buffer.c... Wrote /home/capitaomorte/Source/Emacs/emacs/src/buffer.c Finding changes in /home/capitaomorte/Source/Emacs/emacs/src/buffer.c...done You can run the command =E2=80=98vc-diff=E2=80=99 with C-x v =3D Finding changes in /home/capitaomorte/Source/Emacs/emacs/src/buffer.c...done Mark set [2 times] Quit Configured using: 'configure --with-modules --with-x-toolkit=3Dlucid' Configured features: XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS NOTIFY GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 MODULES Important settings: value of $LC_CTYPE: en_US.UTF-8 value of $LC_MONETARY: pt_PT.UTF-8 value of $LC_NUMERIC: pt_PT.UTF-8 value of $LC_TIME: pt_PT.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix Major mode: Diff Minor modes in effect: global-aggressive-indent-mode: t shell-dirtrack-mode: t sly-autodoc-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-match-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-netsplit-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t diff-auto-refine-mode: t whitespace-mode: t electric-pair-mode: t ido-everywhere: t delete-selection-mode: t global-auto-revert-mode: t show-paren-mode: t yas-global-mode: t yas-minor-mode: t cl-old-struct-compat-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: ~/Source/Emacs/darkroom/darkroom hides /home/capitaomorte/.emacs.d/elpa/dar= kroom-0.1/darkroom Features: (shadow sort emacsbug sendmail descr-text crm aggressive-indent tabify hanja-util vc-annotate vc-filewise smerge-mode vc-dir trace ibuf-ext ibuffer ibuffer-loaddefs sly-named-readtables sly-fancy sly-tramp tramp tramp-compat tramp-loaddefs trampver ucs-normalize shell parse-time sly-indentation sly-cl-indent cl-indent sly-stickers color hi-lock sly-trace-dialog sly-fontifying-fu sly-package-fu sly-scratch sly-fancy-trace sly-fancy-inspector sly-autodoc sly-parse sly-mrepl network-stream nsm starttls tls gnutls sly info gud sly-completion sly-buttons sly-messages sly-common apropos arc-mode archive-mode noutline outline hyperspec browse-url display-line-numbers mail-extr ffap etags log-view semantic/symref/grep semantic/symref semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs erc-list erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete erc-track erc-match erc-button erc-fill erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat cua-rect rect cua-base eieio-opt speedbar sb-image ezimage dframe edebug disass perl-mode flymake-tests pulse warnings imenu base16-hopscotch-theme base16-irblack-theme base16-isotope-theme base16-london-tube-theme base16-default-light-theme base16-eighties-theme base16-chalk-theme base16-solarflare-theme base16-tomorrow-theme base16-theme cus-theme hippie-exp bug-reference cl-print ert-x ert find-func ewoc debug help-fns radix-tree misearch multi-isearch vc-git diff-mode linum hideshow whitespace cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-langs cc-vars cc-defs cc-bytecomp git-rebase-mode thingatpt darkroom face-remap sly-named-readtables-autoloads sly-autoloads flymake-easy flymake flymake-proc flymake-ui rust-mode json map pp cus-edit cus-start cus-load wid-edit epa-file windmove ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff elec-pair ido delsel autorevert filenotify paren server log-edit message puny dired-x dired desktop frameset pcase dired-loaddefs subr-x format-spec rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log grep compile comint ansi-color vc vc-dispatcher advice xref project ring cl-extra yasnippet help-mode easy-mmode edmacro kmacro holy cl finder-inf rx package easymenu epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 930795 207805) (symbols 48 50058 1) (miscs 40 3425 957) (strings 32 147889 13156) (string-bytes 1 5467904) (vectors 16 73522) (vector-slots 8 1956561 77022) (floats 8 329 1718) (intervals 56 33152 527) (buffers 992 148)) From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 04:40:16 2017 Received: (at 28390) by debbugs.gnu.org; 8 Sep 2017 08:40:16 +0000 Received: from localhost ([127.0.0.1]:55260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqEpk-00009n-97 for submit@debbugs.gnu.org; Fri, 08 Sep 2017 04:40:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqEpi-00009Z-JY for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 04:40:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqEpY-00008E-UY for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 04:40:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqEpO-0008Ox-W1; Fri, 08 Sep 2017 04:39:55 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3289 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dqEpO-0003hg-Au; Fri, 08 Sep 2017 04:39:54 -0400 Date: Fri, 08 Sep 2017 11:39:59 +0300 Message-Id: <83tw0dy468.fsf@gnu.org> From: Eli Zaretskii To: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) In-reply-to: <871snijgkk.fsf@lolita> (joaotavora@gmail.com) Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority References: <871snijgkk.fsf@lolita> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28390 Cc: 28390@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: joaotavora@gmail.com (João Távora) > Date: Thu, 07 Sep 2017 23:21:15 +0100 > > Hi Stefan, maintainters > > I believe I found a rather easy glitch in the doc of overlays-at. It > says if SORTED in non-nil it sorts overlays by "decreasing" priority, > but actually the reverse is true. > > Line 3234 of buffer.c seems to confirm this: > > /* Sort the overlays into the proper order: increasing priority. */ > > and compare_overlays passed to qsort() as well: > > return s1->priority < s2->priority ? -1 : 1; > > I also did this test: > > (progn > (mapc #'delete-overlay (overlays-in (point-min) (point-max))) > (dotimes (i 4) (overlay-put (make-overlay 20 30) 'priority i)) > (mapcar (lambda (ov) (overlay-get ov 'priority)) (overlays-at 20 t))) > > this returns (0 1 2 3) > > This is a 3-year-old docbug, so I'm suspicious I might be missing > something. Anyway here's a docpatch. I think the doc string says what the implementation was supposed to do, so we need to change the implementation instead. If you look at the changeset where the SORTED argument was introduced, you will see that the old code sorted the list returned by overlays-at in descending order of priorities, i.e. overlays with the largest priority first. It used 'sort' like this: (sort (mapcar #'overlay-properties (overlays-at p)) (lambda (A B) (> (or (cadr (memq 'priority A)) 0) (or (cadr (memq 'priority B)) 0))))) The doc string of 'sort' says that its PREDICATE function should return non-nil if the first element passed to PREDICATE should sort _before_ the second. And the predicate above uses '>'. So I think we should rather reverse the list which overlays-at returns. Stefan? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 04:57:39 2017 Received: (at 28390) by debbugs.gnu.org; 8 Sep 2017 08:57:39 +0000 Received: from localhost ([127.0.0.1]:55282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqF6Z-0002On-7r for submit@debbugs.gnu.org; Fri, 08 Sep 2017 04:57:39 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:45380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqF6X-0002OX-5c for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 04:57:37 -0400 Received: by mail-wm0-f51.google.com with SMTP id f199so814528wme.0 for <28390@debbugs.gnu.org>; Fri, 08 Sep 2017 01:57:37 -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=JcF1KUwegq00H6xOkKfF0jIGQrf/rStq++1VEa7pCDs=; b=Qb6O16+kxXxoi2Bas9akFGyJzV5GhvqNPtkEvxhIVunYnI9dKCyuOAUQsXKUce96Pg VgAG13Y+GV/gJDzSk9ZXcACSMV3+Vh76xTx1o0b+o2YZNeJIzOtdyAb6+42Fj0UrpEBG 61AUP/6+ZeU19EOIvPZpSYQGd5lyWHlVywlMNzqplqYZNu4XOBrrRsE2GWm5ZavX5Jdi TzjLA8l1vxfXlLUXWoApiI7BiA4G2Nx37HgTIhXU4cUFMqPU2D5me6HxM2ljGblWwS4Y zbM4w10zQtzFJ45ctRJhpwRKLXbHEhmGAKf4lamTde2B7q18zpf4bjb699H0y0/m/h3P XwoA== 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=JcF1KUwegq00H6xOkKfF0jIGQrf/rStq++1VEa7pCDs=; b=kCUnNVV38J2NOY2W4Csrr0y8R53hy6/N3IdEI0OKHDQPOs8Ed6YbXW4AYHlDzcYcva 8x5AT0y8ee74SoVKoLtzRCFgMAH18KnyeWiHSRgzFVlBZbkyaNbPvnUDM7e+Nva2vfkU e1F0GoQwei/xYLLiS/gyUXif5Y1+ekTbdHzvgXJReGSKi0lAgU3wf2LrN2DLuL0ASuLe ZBkLDwqGgi9Y7c0QlIUvqRA8XIaRA1RB7TUKP3BCHkqIxjhZXGE1SYidMxULhbPq7thp n1ZcSqwOqYq7YUoLk3RwnkRh3hVW4jZUVsck8OaUdkYleGLC6kanZGoHUmuSs1DdQdvi nx8g== X-Gm-Message-State: AHPjjUi23QYDFOySmlN9Pa8V2AsmbyzlyzxDvnjulWmp2i49Vmpylpym mF0eHWr/uZPsqO4du4Tg6x12tPCBomc= X-Google-Smtp-Source: AOwi7QCTRMwpElwXlIXLWv9E40wC1foLA2WTLTfBm1glCJShnVS6ugjyDOZUZrQ6cEBNSjnLnhWH1A== X-Received: by 10.28.152.4 with SMTP id a4mr147535wme.29.1504861051143; Fri, 08 Sep 2017 01:57:31 -0700 (PDT) Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id p29sm872926wma.30.2017.09.08.01.57.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Sep 2017 01:57:30 -0700 (PDT) From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) To: Eli Zaretskii Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority References: <871snijgkk.fsf@lolita> <83tw0dy468.fsf@gnu.org> Date: Fri, 08 Sep 2017 09:57:28 +0100 In-Reply-To: <83tw0dy468.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 08 Sep 2017 11:39:59 +0300") Message-ID: <87r2vhin47.fsf@lolita> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28390 Cc: 28390@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Eli Zaretskii writes: >> From: joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) >> Date: Thu, 07 Sep 2017 23:21:15 +0100 >>=20 >> Hi Stefan, maintainters >>=20 >> I believe I found a rather easy glitch in the doc of overlays-at. It >> says if SORTED in non-nil it sorts overlays by "decreasing" priority, >> but actually the reverse is true. >>=20 >> Line 3234 of buffer.c seems to confirm this: >>=20 >> /* Sort the overlays into the proper order: increasing priority. */ >>=20 >> and compare_overlays passed to qsort() as well: >>=20 >> return s1->priority < s2->priority ? -1 : 1; >>=20 >> I also did this test: >>=20 >> (progn >> (mapc #'delete-overlay (overlays-in (point-min) (point-max))) >> (dotimes (i 4) (overlay-put (make-overlay 20 30) 'priority i)) >> (mapcar (lambda (ov) (overlay-get ov 'priority)) (overlays-at 20 t)= )) >>=20 >> this returns (0 1 2 3) >>=20 >> This is a 3-year-old docbug, so I'm suspicious I might be missing >> something. Anyway here's a docpatch. > > I think the doc string says what the implementation was supposed to > do, so we need to change the implementation instead. Really? Won't that ripple very paintuflly across the elisp ecosphere? > If you look at the changeset where the SORTED argument was introduced, > you will see that the old code sorted the list returned by overlays-at > in descending order of priorities, i.e. overlays with the largest > priority first. It used 'sort' like this: > > (sort (mapcar #'overlay-properties (overlays-at p)) > (lambda (A B) (> (or (cadr (memq 'priority A)) 0) > (or (cadr (memq 'priority B)) 0))))) I don't follow, where is the code that did this, or is this just an illustration? The optional SORTED to overlays-at is first introduced in buffer.c in Stefan's 20fa59a0 commit. Before that, I see no evidence of explicit sorting. DEFUN("overlays-at") calls sort_overlays(), which has always used qsort() with compare_overlays(), which in turn always returned negatives if prio1 < prio2. (always ~=3D since 1994) > The doc string of 'sort' says that its PREDICATE function should > return non-nil if the first element passed to PREDICATE should sort > _before_ the second. And the predicate above uses '>'. But where was sort() ever used before Stefan's 2014 change? Did overlays-at make any sort guarantee back then? I do agree that it should sort the other way, though. But it's too late for that, bugs will be features :-). From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 05:47:19 2017 Received: (at 28390) by debbugs.gnu.org; 8 Sep 2017 09:47:19 +0000 Received: from localhost ([127.0.0.1]:55324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqFsc-0003aC-Ps for submit@debbugs.gnu.org; Fri, 08 Sep 2017 05:47:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqFsb-0003a0-BL for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 05:47:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqFsR-0004AM-Dz for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 05:47:12 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqFsH-0003qg-5n; Fri, 08 Sep 2017 05:46:57 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3345 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dqFsG-0001cB-H0; Fri, 08 Sep 2017 05:46:57 -0400 Date: Fri, 08 Sep 2017 12:47:02 +0300 Message-Id: <83lglpy12h.fsf@gnu.org> From: Eli Zaretskii To: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) In-reply-to: <87r2vhin47.fsf@lolita> (joaotavora@gmail.com) Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority References: <871snijgkk.fsf@lolita> <83tw0dy468.fsf@gnu.org> <87r2vhin47.fsf@lolita> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28390 Cc: 28390@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: joaotavora@gmail.com (João Távora) > Cc: 28390@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Fri, 08 Sep 2017 09:57:28 +0100 > > Eli Zaretskii writes: > > > I think the doc string says what the implementation was supposed to > > do, so we need to change the implementation instead. > > Really? Won't that ripple very paintuflly across the elisp ecosphere? I don't think so. I believe this optional argument is used very rarely. > > If you look at the changeset where the SORTED argument was introduced, > > you will see that the old code sorted the list returned by overlays-at > > in descending order of priorities, i.e. overlays with the largest > > priority first. It used 'sort' like this: > > > > (sort (mapcar #'overlay-properties (overlays-at p)) > > (lambda (A B) (> (or (cadr (memq 'priority A)) 0) > > (or (cadr (memq 'priority B)) 0))))) > > I don't follow, where is the code that did this, or is this just an > illustration? This is the code which was replaced when overlays-at got its optional argument in that Stefan's change. > > The doc string of 'sort' says that its PREDICATE function should > > return non-nil if the first element passed to PREDICATE should sort > > _before_ the second. And the predicate above uses '>'. > > But where was sort() ever used before Stefan's 2014 change? Did > overlays-at make any sort guarantee back then? Look at the changeset of commit 20fa59a0, you will see that the uses if 'sort' were replaced with calls to overlays-at with the new optional argument. > I do agree that it should sort the other way, though. But it's too late > for that, bugs will be features :-). I'm not sure it's too late. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 15:31:14 2017 Received: (at 28390) by debbugs.gnu.org; 8 Sep 2017 19:31:15 +0000 Received: from localhost ([127.0.0.1]:56391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqOzi-0006S9-MS for submit@debbugs.gnu.org; Fri, 08 Sep 2017 15:31:14 -0400 Received: from mail-qk0-f176.google.com ([209.85.220.176]:36534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqOzg-0006Rv-Uc for 28390@debbugs.gnu.org; Fri, 08 Sep 2017 15:31:13 -0400 Received: by mail-qk0-f176.google.com with SMTP id z143so8665833qkb.3 for <28390@debbugs.gnu.org>; Fri, 08 Sep 2017 12:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=vj+PI7cJ1P3SWHReNnRFG4fXraDAM/Yr5PNM5gobVjI=; b=Ht1OsUOrMs1k62w5hiZBQTIXNlHGEMEPZ/0O7FJNvBdg2baEB7BW29EmYePwOfGiq7 sNKH1U+EqFLODwX1OVAeoJpXxbHw3ncSOzF570RMcOSMP/R8ho0pPFBvmqUoEtohiMqx VN1Pvh3+QTe8amxpGuLp7wQ0sFiuXeYN3Brys1bSOw9l1I+uJyKlX7S56DPnoYbrUp0Q 3YJ7Xw6KtlWahVVFd4XLcVYxAD+7kqRmceJHRG0rJXTOzbUYvt3Z1dv+sJjNme7Uhj8a obnXhG6v9nxB+hY5XiuDME6no4ghi1+bIUG0+Y9BawFAXztTjaylc1ZmrF938gK7V/zu mTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=vj+PI7cJ1P3SWHReNnRFG4fXraDAM/Yr5PNM5gobVjI=; b=rBeUCGfqdg1zV9Ac/jH3ywEAZeYRUC/gvLeA4Hil+jCtjEZcwVd1onWBaPVYKLnjiX UF112ZEPRe4XAtGw50OnfKyBs4rC6hZzrxPvUvkE8+zGNy8tJR7o5gJX/QmGtDSMqe05 Eg2qiod5Cc7+IlRjsnMOO6ig33hR8rtdX1/TlQOHkJgH9pzeqqiX22YtjQwUqWU+NDSK wmeb+IlvbzlRVstPL8YeDQ7dCPTdfQRIIygVXVT8j0KRGNGJVSolVXo9+Am8y6gMvOcs aAUWtqADW8w5ClB2ueS1nD9/ENuE+SQREzVwqsslyITLUz1/cbH47FSxnH5DTY4FJnUv aWpw== X-Gm-Message-State: AHPjjUhC2hcgn3e0MqG3Uu73kCXieouxkhvTNWgt1m4LcO6g2qymwutK i5KlVIIYXqv7fBurZBOYA0rEYi1TpyHI X-Google-Smtp-Source: AOwi7QCngVLJQeLu1r9ZnIzgVQp96ZPYDSLe6LLMlJdTwLX8ns2hb+IxeZyUyodx7Cze22vPPpw7FF7ktQoqCPKkilM= X-Received: by 10.55.42.216 with SMTP id q85mr5207921qkq.337.1504899067131; Fri, 08 Sep 2017 12:31:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.177.130 with HTTP; Fri, 8 Sep 2017 12:30:46 -0700 (PDT) In-Reply-To: References: <871snijgkk.fsf@lolita> <83tw0dy468.fsf@gnu.org> <87r2vhin47.fsf@lolita> <83lglpy12h.fsf@gnu.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 8 Sep 2017 20:30:46 +0100 Message-ID: Subject: Fwd: bug#28390: 26.0.50; overlays-at actually sorts by increating priority To: 28390@debbugs.gnu.org, Stefan Monnier Content-Type: multipart/alternative; boundary="001a1147b36251bce40558b29e88" X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 28390 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) --001a1147b36251bce40558b29e88 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message ---------- From: Jo=C3=A3o T=C3=A1vora Date: Fri, Sep 8, 2017 at 7:48 PM Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority To: Eli Zaretskii On Fri, Sep 8, 2017 at 10:47 AM, Eli Zaretskii wrote: > > > > Really? Won't that ripple very paintuflly across the elisp ecosphere? > > I don't think so. I believe this optional argument is used very > rarely. > > > I do agree that it should sort the other way, though. But it's too late > > for that, bugs will be features :-). > > I'm not sure it's too late. You might be right. Even I overestimated how much I use it in my libs. I don't. And the few first pages of a github code search for overlays-at don't disprove you. But they don't prove anything either. Anyway, your call. I wouldn't do it, what's to gain besides consistency? --=20 Jo=C3=A3o T=C3=A1vora --001a1147b36251bce40558b29e88 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
---------- Forwarded message --= --------
From: Jo=C3=A3o T=C3=A1vora <= span dir=3D"ltr"><joaotavora@gma= il.com>
Date: Fri, Sep 8, 2017 at 7:48 PM
Subject: Re: = bug#28390: 26.0.50; overlays-at actually sorts by increating priority
To= : Eli Zaretskii <eliz@gnu.org>

On Fri, Sep 8= , 2017 at 10:47 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > Really? = Won't that ripple very paintuflly across the elisp ecosphere?
>> I don't think so.=C2=A0 I believe this optional argument is used= very
> rarely.
>
> > I do agr= ee that it should sort the other way, though. But it's too late
>= > for that, bugs will be features :-).
>
> I'm not sure= it's too late.

You might be right. Even I overestimated how much I us= e it in my libs. I don't.=C2=A0

And the few first pages of a github code sear= ch for overlays-at don't disprove=C2=A0
you. But they don't prove anything either.=C2=A0

Anyway, your call. I wouldn= 't do it, what's to gain besides consistency?

--
Jo=C3=A3o T=C3=A1vora
--001a1147b36251bce40558b29e88-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 10 09:53:13 2017 Received: (at 28390) by debbugs.gnu.org; 10 Sep 2017 13:53:13 +0000 Received: from localhost ([127.0.0.1]:58615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dr2fh-0007ql-K7 for submit@debbugs.gnu.org; Sun, 10 Sep 2017 09:53:13 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:38333) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dr2ff-0007qd-5r for 28390@debbugs.gnu.org; Sun, 10 Sep 2017 09:53:12 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v8ADr75l003068; Sun, 10 Sep 2017 09:53:09 -0400 Received: by ceviche.home (Postfix, from userid 20848) id AF53B66375; Sun, 10 Sep 2017 09:53:07 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority Message-ID: References: <871snijgkk.fsf@lolita> <83tw0dy468.fsf@gnu.org> Date: Sun, 10 Sep 2017 09:53:07 -0400 In-Reply-To: <83tw0dy468.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 08 Sep 2017 11:39:59 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 3 Rules triggered GEN_SPAM_FEATRE=0.1, EDT_SA_DN_PASS=0, RV6112=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6112> : inlines <6061> : streams <1762412> : uri <2498110> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 28390 Cc: 28390@debbugs.gnu.org, =?windows-1252?B?Sm/jbyBU4XZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > So I think we should rather reverse the list which overlays-at > returns. Stefan? No preference on my side, Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 16 06:04:29 2017 Received: (at 28390-done) by debbugs.gnu.org; 16 Sep 2017 10:04:29 +0000 Received: from localhost ([127.0.0.1]:43358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dt9xd-0006Y4-8I for submit@debbugs.gnu.org; Sat, 16 Sep 2017 06:04:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dt9xc-0006Xs-8Q for 28390-done@debbugs.gnu.org; Sat, 16 Sep 2017 06:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dt9xT-0008BR-SA for 28390-done@debbugs.gnu.org; Sat, 16 Sep 2017 06:04:23 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt9xT-0008BM-Oj; Sat, 16 Sep 2017 06:04:19 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4894 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dt9xQ-0003l7-E3; Sat, 16 Sep 2017 06:04:17 -0400 Date: Sat, 16 Sep 2017 13:04:22 +0300 Message-Id: <838thfkli1.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-reply-to: (message from Stefan Monnier on Sun, 10 Sep 2017 09:53:07 -0400) Subject: Re: bug#28390: 26.0.50; overlays-at actually sorts by increating priority References: <871snijgkk.fsf@lolita> <83tw0dy468.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28390-done Cc: 28390-done@debbugs.gnu.org, joaotavora@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Stefan Monnier > Cc: joaotavora@gmail.com (João Távora), > 28390@debbugs.gnu.org > Date: Sun, 10 Sep 2017 09:53:07 -0400 > > > So I think we should rather reverse the list which overlays-at > > returns. Stefan? > > No preference on my side, Done, and closing the bug report. Thanks. From unknown Tue Aug 19 12:51:15 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 14 Oct 2017 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator