From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: text_property_stickiness() ignores `text-property-default-nonsticky' Date: Mon, 04 Jul 2011 12:53:00 -0400 Message-ID: References: <87aacuq5p2.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1309798414 689 80.91.229.12 (4 Jul 2011 16:53:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2011 16:53:34 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Kurochkin Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 04 18:53:30 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QdmOn-0002AJ-Fo for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2011 18:53:29 +0200 Original-Received: from localhost ([::1]:38987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdmOm-0000ZJ-Ba for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2011 12:53:28 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdmOR-0000Yo-1X for emacs-devel@gnu.org; Mon, 04 Jul 2011 12:53:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdmOP-0005oB-KS for emacs-devel@gnu.org; Mon, 04 Jul 2011 12:53:06 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:58307 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdmOP-0005ns-8S for emacs-devel@gnu.org; Mon, 04 Jul 2011 12:53:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAF/vEU5FxIxr/2dsb2JhbABTp3t4iHrAf4Y2BJpMgTSCXIQs X-IronPort-AV: E=Sophos;i="4.65,473,1304308800"; d="scan'208";a="120394225" Original-Received: from 69-196-140-107.dsl.teksavvy.com (HELO pastel.home) ([69.196.140.107]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 04 Jul 2011 12:53:01 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id A0B1759173; Mon, 4 Jul 2011 12:53:00 -0400 (EDT) In-Reply-To: <87aacuq5p2.fsf@gmail.com> (Dmitry Kurochkin's message of "Mon, 04 Jul 2011 03:56:25 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:141541 Archived-At: >>>>> "Dmitry" == Dmitry Kurochkin writes: > Hello. > I am trying to make `keymap' property rear-nonsticky, so that it does > not affect the next character after the region the property is applied > to. If I do it by setting rear-nonsticky text property to 't or to a > list that contains 'keymap, it works fine: > (let ((map (make-sparse-keymap))) > (define-key map (kbd "RET") 'bug) > (switch-to-buffer "test") > (insert "123456") > (put-text-property 1 4 'keymap map) > (put-text-property (point-min) (point-max) 'rear-nonsticky '(keymap)) > (goto-char 4) > (message "keymap: %s" (get-text-property (point) 'keymap)) > (message "key-binding: %s" (key-binding (kbd "RET")))) > But if I set `text-property-default-nonsticky' variable instead, it does > not work: > (let ((map (make-sparse-keymap))) > (define-key map (kbd "RET") 'bug) > (switch-to-buffer "test") > (insert "123456") > (put-text-property 1 4 'keymap map) > (make-local-variable 'text-property-default-nonsticky) > (add-to-list 'text-property-default-nonsticky '(keymap . t)) > (goto-char 4) > (message "keymap: %s" (get-text-property (point) 'keymap)) > (message "key-binding: %s" (key-binding (kbd "RET")))) > Looking through the code, I got down to text_property_stickiness() > function in src/textprop.c, which is used by get_pos_property(), which > is used by get_local_map(). There are checks for `front-sticky' and > `rear-nonsticky' properties, but no checks for > `text-property-default-nonsticky' variable. Indeed. Does the patch below fix your problem? > Before opening false bug reports, I would like to confirm that this is > an issue indeed, and it is not me doing something stupid. "False" bug reports are not something you should be afraid of. I.e. feel free to use M-x report-emacs-bug when something looks like a bug *to you*, even if we decide that it's a not a bug from our point of view. Stefan === modified file 'src/textprop.c' --- src/textprop.c 2011-06-25 13:00:55 +0000 +++ src/textprop.c 2011-07-04 16:49:42 +0000 @@ -1707,10 +1707,14 @@ { Lisp_Object prev_pos, front_sticky; int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */ + Lisp_Object default = Fassq (prop, Vtext_property_default_nonsticky); if (NILP (buffer)) XSETBUFFER (buffer, current_buffer); + if (CONSP (default) && NILP (XCDR (default))) + is_rear_sticky = 0; + if (XINT (pos) > BUF_BEGV (XBUFFER (buffer))) /* Consider previous character. */ {