unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: emacs-devel@gnu.org
Cc: Thien-Thi Nguyen <ttn@gnu.org>
Subject: Re: [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’.
Date: Sun, 15 Jan 2017 21:32:19 -0500	[thread overview]
Message-ID: <jwvy3ybspoj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20170115231126.DB46722017C@vcs.savannah.gnu.org> (Thien-Thi Nguyen's message of "Sun, 15 Jan 2017 23:11:26 +0000 (UTC)")

> +  ;; GNU Emacs 25.1 looks askance at ‘intangible’, 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)))))
 
+(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 (= (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."
 
 (defun gnugo-merge-showboard-results ()
   (let ((aft (substring (gnugo--q "showboard") 3))
-        (adj 1)                         ; string to buffer position adjustment
+        (adj (point-min))       ; String to buffer position adjustment.
 
         (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-sticky')
-        (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--intangible))
+          (put-text-property cut (1+ cut) gnugo--intangible very-strange))))))
 
 (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 ‘intangible’, 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."
 
 \f
 ;;;---------------------------------------------------------------------------
-;;; The remainder of this file defines a simplified SGF-handling library.
-;;; When/if it should start to attain generality, it should be split off into
-;;; 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 into
+;; a separate file (probably named sgf.el) w/ funcs and vars renamed sans the
+;; "gnugo/" prefix.
 
 (defconst gnugo/sgf-*r4-properties*
   '((AB "Add Black"       setup list stone)



       reply	other threads:[~2017-01-16  2:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170115231126.7513.20697@vcs.savannah.gnu.org>
     [not found] ` <20170115231126.DB46722017C@vcs.savannah.gnu.org>
2017-01-16  2:32   ` Stefan Monnier [this message]
2017-01-19  7:16     ` [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’ Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy3ybspoj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=ttn@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).