From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
Newsgroups: gmane.emacs.devel
Subject: Re: [elpa] master cf9edfa 3/5: [gnugo slog] Clear
	=?utf-8?Q?=E2=80=98inhibit-point-motion-hooks=E2=80=99=2E?=
Date: Sun, 15 Jan 2017 21:32:19 -0500
Message-ID: <jwvy3ybspoj.fsf-monnier+emacs@gnu.org>
References: <20170115231126.7513.20697@vcs.savannah.gnu.org>
	<20170115231126.DB46722017C@vcs.savannah.gnu.org>
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 1484533974 20032 195.159.176.226 (16 Jan 2017 02:32:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 16 Jan 2017 02:32:54 +0000 (UTC)
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)
Cc: Thien-Thi Nguyen <ttn@gnu.org>
To: emacs-devel@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 16 03:32:50 2017
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Envelope-to: ged-emacs-devel@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 <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1cSx62-0003Q8-Eh
	for ged-emacs-devel@m.gmane.org; Mon, 16 Jan 2017 03:32:34 +0100
Original-Received: from localhost ([::1]:53809 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1cSx65-0000Az-Gw
	for ged-emacs-devel@m.gmane.org; Sun, 15 Jan 2017 21:32:37 -0500
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44474)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <monnier@iro.umontreal.ca>) id 1cSx5w-00009n-SJ
	for emacs-devel@gnu.org; Sun, 15 Jan 2017 21:32:30 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <monnier@iro.umontreal.ca>) id 1cSx5v-0000xg-K2
	for emacs-devel@gnu.org; Sun, 15 Jan 2017 21:32:28 -0500
Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:39115)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <monnier@iro.umontreal.ca>)
	id 1cSx5r-0000tk-QC; Sun, 15 Jan 2017 21:32:23 -0500
Original-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 v0G2WKx0008516; 
	Sun, 15 Jan 2017 21:32:20 -0500
Original-Received: by ceviche.home (Postfix, from userid 20848)
	id F3A7C661CB; Sun, 15 Jan 2017 21:32:19 -0500 (EST)
In-Reply-To: <20170115231126.DB46722017C@vcs.savannah.gnu.org> (Thien-Thi
	Nguyen's message of "Sun, 15 Jan 2017 23:11:26 +0000 (UTC)")
X-NAI-Spam-Flag: NO
X-NAI-Spam-Level: 
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0.4
X-NAI-Spam-Rules: 4 Rules triggered
	PHONE_800=0.3, BOUNCE_SUBJ_UTF8=0.1, EDT_SA_DN_PASS=0, RV5920=0
X-NAI-Spam-Version: 2.3.0.9418 : core <5920> : inlines <5627> : streams
	<1729264> : uri <2358816>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 132.204.246.20
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel/>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel" <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.devel:211315
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/211315>

> +  ;; GNU Emacs 25.1 looks askance at =E2=80=98intangible=E2=80=99, sigh.
> +  (setq-local inhibit-point-motion-hooks nil)

How 'bout the patch below (which additionally gets you rid of the place
where you modify a string in-place, which I find very untoward).

>From the bit of testing I've done, the intangibility on your board is
a bit flimsy (C-f/C-b can move off the board), but I haven't tried to
change that.


        Stefan


diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index a9e03aaa4..6a3eb0b65 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -636,6 +636,9 @@ when you are sure the command cannot fail."
               :nogrid)
      (save-excursion (gnugo-refresh)))))
=20
+(defconst gnugo--intangible
+  (if (fboundp 'cursor-intangible-mode) 'cursor-intangible 'intangible))
+
 (defun gnugo-propertize-board-buffer ()
   (erase-buffer)
   (insert (substring (gnugo--q "showboard") 3))
@@ -703,7 +706,7 @@ when you are sure the command cannot fail."
                                    (gnugo-position gnugo-yin))))
           (unless (=3D (1- other-edge) p)
             (add-text-properties (1+ p) (+ 2 p) ispc-props)
-            (put-text-property p (+ 2 p) 'intangible ival)))
+            (put-text-property p (+ 2 p) gnugo--intangible ival)))
         (add-text-properties (1+ other-edge) right-empty grid-props)
         (goto-char right-empty)
         (when (looking-at "\\s-+\\(WH\\|BL\\).*capt.* \\([0-9]+\\).*$")
@@ -725,7 +728,7 @@ when you are sure the command cannot fail."
=20
 (defun gnugo-merge-showboard-results ()
   (let ((aft (substring (gnugo--q "showboard") 3))
-        (adj 1)                         ; string to buffer position adjust=
ment
+        (adj (point-min))       ; String to buffer position adjustment.
=20
         (sync "[0-9]* stones$")
         ;; Note: `sync' used to start w/ "[0-9]+", but that is too
@@ -797,8 +800,9 @@ when you are sure the command cannot fail."
         (delete-char 1)
         ;; do this last to avoid complications w/ font lock
         ;; (this also means we cannot include `intangible' in `front-stick=
y')
-        (when (setq very-strange (get-text-property (1+ cut) 'intangible))
-          (put-text-property cut (1+ cut) 'intangible very-strange))))))
+        ;; FIXME: This care is probably not needed for cursor-intangible.
+        (when (setq very-strange (get-text-property (1+ cut) gnugo--intang=
ible))
+          (put-text-property cut (1+ cut) gnugo--intangible very-strange))=
))))
=20
 (defsubst gnugo--move-prop (node)
   (or (assq :B node)
@@ -1249,34 +1253,36 @@ its move."
         (setq cur gnugo-mode-line)
         (gnugo-put :mode-line cur)
         (gnugo-put :mode-line-form
-          (cond ((stringp cur)
-                 (setq cur (copy-sequence cur))
-                 (let (acc cut c)
-                   (while (setq cut (string-match "~[bwpmtu]" cur))
-                     (aset cur cut ?%)
-                     (setq c (aref cur (cl-incf cut)))
-                     (aset cur cut ?s)
-                     (push
-                      `(,(intern (format "squig-%c" c))
-                        ,(cl-case c
-                           (?b '(or (gnugo-get :black-captures) 0))
-                           (?w '(or (gnugo-get :white-captures) 0))
-                           (?p '(gnugo-current-player))
-                           (?t '(let ((ws (gnugo-get :waiting-start)))
-                                  (if ws
-                                      (cadr (time-since ws))
-                                    "-")))
-                           (?u '(or (gnugo-get :last-waiting) "-"))
-                           (?m '(let ((tree (gnugo-get :sgf-gametree))
-                                      (monkey (gnugo-get :monkey)))
-                                  (gethash (car (aref monkey 0))
-                                           (gnugo--tree-mnum tree)
-                                           ;; should be unnecessary
-                                           "?")))))
-                      acc))
-                   `(let ,(delete-dups (copy-sequence acc))
-                      (format ,cur ,@(reverse (mapcar 'car acc))))))
-                (t cur))))
+          (if (not (stringp cur))
+              cur
+            (let* ((acc ())
+                   (fmt
+                    (replace-regexp-in-string
+                     "~[bwpmtu]"
+                     (lambda (match)
+                       (prog1 "%s"
+                         (let ((c (aref match 1)))
+                           (push
+                            `(,(intern (format "squig-%c" c))
+                              ,(cl-case c
+                                 (?b '(or (gnugo-get :black-captures) 0))
+                                 (?w '(or (gnugo-get :white-captures) 0))
+                                 (?p '(gnugo-current-player))
+                                 (?t '(let ((ws (gnugo-get :waiting-start)=
))
+                                        (if ws
+                                            (cadr (time-since ws))
+                                          "-")))
+                                 (?u '(or (gnugo-get :last-waiting) "-"))
+                                 (?m '(let ((tree (gnugo-get :sgf-gametree=
))
+                                            (monkey (gnugo-get :monkey)))
+                                        (gethash (car (aref monkey 0))
+                                                 (gnugo--tree-mnum tree)
+                                                 ;; should be unnecessary
+                                                 "?")))))
+                            acc))))
+                     cur t t)))
+              `(let ,(delete-dups (copy-sequence acc))
+                 (format ,fmt ,@(reverse (mapcar #'car acc))))))))
       (let ((form (gnugo-get :mode-line-form)))
         (setq mode-line-process
               (and form
@@ -2145,8 +2151,8 @@ In this mode, keys do not self insert."
   (setq font-lock-defaults '(gnugo-font-lock-keywords t)
         truncate-lines t)
   (add-hook 'kill-buffer-hook 'gnugo-cleanup nil t)
-  ;; GNU Emacs 25.1 looks askance at =E2=80=98intangible=E2=80=99, sigh.
-  (setq-local inhibit-point-motion-hooks nil)
+  (if (eq gnugo--intangible 'cursor-intangible)
+      (cursor-intangible-mode 1))
   (setq-local gnugo-state (gnugo--mkht :size (1- 42)))
   (setq-local gnugo-btw nil)
   (add-to-list 'minor-mode-alist '(gnugo-btw gnugo-btw))
@@ -2404,10 +2410,10 @@ See `gnugo-board-mode' for a full list of commands."
=20
 
 ;;;-----------------------------------------------------------------------=
----
-;;; The remainder of this file defines a simplified SGF-handling library.
-;;; When/if it should start to attain generality, it should be split off i=
nto
-;;; a separate file (probably named sgf.el) w/ funcs and vars renamed sans=
 the
-;;; "gnugo/" prefix.
+;; The remainder of this file defines a simplified SGF-handling library.
+;; When/if it should start to attain generality, it should be split off in=
to
+;; a separate file (probably named sgf.el) w/ funcs and vars renamed sans =
the
+;; "gnugo/" prefix.
=20
 (defconst gnugo/sgf-*r4-properties*
   '((AB "Add Black"       setup list stone)