unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’.
       [not found] ` <20170115231126.DB46722017C@vcs.savannah.gnu.org>
@ 2017-01-16  2:32   ` Stefan Monnier
  2017-01-19  7:16     ` Thien-Thi Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2017-01-16  2:32 UTC (permalink / raw)
  To: emacs-devel; +Cc: Thien-Thi Nguyen

> +  ;; 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)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’.
  2017-01-16  2:32   ` [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’ Stefan Monnier
@ 2017-01-19  7:16     ` Thien-Thi Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thien-Thi Nguyen @ 2017-01-19  7:16 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]


() Stefan Monnier <monnier@IRO.UMontreal.CA>
() Sun, 15 Jan 2017 21:32:19 -0500

   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).

Thanks.  I have modified the mode-line munging bits to use
‘replace-regexp-in-string’ as exemplified in the patch.  OTOH,
the cursor-intangible parts of the patch i'm still mulling.

   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.

Yeah, it has always been partial.  At the design level, i wonder
what is the preferred user experience when about to move off the
board.  I see these possibilities:

 (a) wrap toroidally (both horiz and vert);
 (b) stay motionless;
 (c) like (b) w/ error;
 (d) do nothing special (status quo).

Personally, i don't mind (d) because i like to explore the text
properties (move point, invoke ‘describe-text-properties’), and
imagine others doing likewise.  (Too, no complaints yet.)

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)
   (pcase (context query)
     (`(technical mailing-list) t)
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-19  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20170115231126.7513.20697@vcs.savannah.gnu.org>
     [not found] ` <20170115231126.DB46722017C@vcs.savannah.gnu.org>
2017-01-16  2:32   ` [elpa] master cf9edfa 3/5: [gnugo slog] Clear ‘inhibit-point-motion-hooks’ Stefan Monnier
2017-01-19  7:16     ` Thien-Thi Nguyen

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).