emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: show-paren-mode vs blink-matching-paren-on-screen


From: Luc Teirlinck
Subject: Re: show-paren-mode vs blink-matching-paren-on-screen
Date: Sat, 26 Nov 2005 12:32:06 -0600 (CST)

Martin Rudalics wrote:

   (1) Invoke Emacs with -q

   Do M-x customize-option RET blink-matching-paren-on-screen RET
   blink-matching-paren-on-screen is "on (non-nil)" its State is STANDARD.
   Hit Finish.

   Do M-x customize-option RET show-paren-mode RET, hit Toggle and Set for
   Current Session.

   Do M-x customize-option RET blink-matching-paren-on-screen RET
   blink-matching-paren-on-screen is now "off (nil)" its State has been
   CHANGED outside Customize; operating on it here may be unreliable.

   But I have not done anything outside customize.

No, but paren.el did.  Richard decided that it is in certain
situations OK for Lisp code to change user options, thereby overriding
the user's customizations.  That will result in a "Changed outside
Customize" state.  I believe that in this particular case (and in many
similar cases as well), there is a less confusing way to handle this.
See the patch below.

The second part of your message points out what seems to be an
undeniable bug:  enabling show-paren-mode might legitimately change the
value of some other option, but certainly enabling and then disabling
show-paren-mode should be a no-op and definitely should not change
the value of any user options.

The patches below correct the bug and also more clearly document the
effect of show-paren-mode on blink-matching-paren-on-screen.  After
the patches, enabling show-paren-mode no longer changes the value of
blink-matching-paren-on-screen, but it results in that value being
ignored and this is pointed out in the
blink-matching-paren-on-screen's docstring.  Disabling
show-paren-mode makes blink-matching-paren-on-screen relevant again.
I believe that this is a much more solid and less confusing way to
handle the situation. 

The patches also eliminate some additional potential problems with
buffer local values.

I can install my patches if desired.

===File ~/simple-diff=======================================
*** simple.el   23 Nov 2005 14:20:12 -0600      1.770
--- simple.el   26 Nov 2005 11:06:06 -0600      
***************
*** 4259,4265 ****
  (defcustom blink-matching-paren-on-screen t
    "*Non-nil means show matching open-paren when it is on screen.
  If nil, means don't show it (but the open-paren can still be shown
! when it is off screen)."
    :type 'boolean
    :group 'paren-blinking)
  
--- 4259,4267 ----
  (defcustom blink-matching-paren-on-screen t
    "*Non-nil means show matching open-paren when it is on screen.
  If nil, means don't show it (but the open-paren can still be shown
! when it is off screen).
! 
! This variable is ignored if `show-paren-mode' is enabled."
    :type 'boolean
    :group 'paren-blinking)
  
***************
*** 4328,4337 ****
         ((pos-visible-in-window-p blinkpos)
          ;; Matching open within window, temporarily move to blinkpos but only
          ;; if `blink-matching-paren-on-screen' is non-nil.
!         (when blink-matching-paren-on-screen
!           (save-excursion
!             (goto-char blinkpos)
!             (sit-for blink-matching-delay))))
         (t
          (save-excursion
            (goto-char blinkpos)
--- 4330,4340 ----
         ((pos-visible-in-window-p blinkpos)
          ;; Matching open within window, temporarily move to blinkpos but only
          ;; if `blink-matching-paren-on-screen' is non-nil.
!         (and blink-matching-paren-on-screen
!              (not show-paren-mode)
!              (save-excursion
!                (goto-char blinkpos)
!                (sit-for blink-matching-delay))))
         (t
          (save-excursion
            (goto-char blinkpos)
============================================================

===File ~/paren-diff========================================
*** paren.el    20 Nov 2005 14:18:52 -0600      1.65
--- paren.el    26 Nov 2005 11:15:31 -0600      
***************
*** 110,123 ****
  When Show Paren mode is enabled, any matching parenthesis is highlighted
  in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
    :global t :group 'paren-showing
!     ;; Turn off the usual paren-matching method
!     ;; when this one is turned on.
!     (if (local-variable-p 'show-paren-mode)
!       (make-local-variable 'blink-matching-paren-on-screen)
!       (kill-local-variable 'blink-matching-paren-on-screen))
!     (setq blink-matching-paren-on-screen (not show-paren-mode))
! 
!     ;; Now enable or disable the mechanism.
      ;; First get rid of the old idle timer.
      (if show-paren-idle-timer
        (cancel-timer show-paren-idle-timer))
--- 110,116 ----
  When Show Paren mode is enabled, any matching parenthesis is highlighted
  in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
    :global t :group 'paren-showing
!     ;; Enable or disable the mechanism.
      ;; First get rid of the old idle timer.
      (if show-paren-idle-timer
        (cancel-timer show-paren-idle-timer))
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]