emacs-devel
[Top][All Lists]
Advanced

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

Re: How global is a define-global-minor-mode mode?


From: Lennart Borgman (gmail)
Subject: Re: How global is a define-global-minor-mode mode?
Date: Fri, 26 Jan 2007 00:56:19 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666

Lennart Borgman (gmail) wrote:

Now back to the tests. If the above was a bit hard to grasp then maybe the test will help. To run the tests first load this file and customize the defcustom, define-minor-mode and define-global-minor-mode, all to t. Then restart Emacs and load the file again and now look in the *Message* buffer for the result.



And here are the tests, sorry ... ;-)
(message "\n\n>>>>>>> defcustom-or-minor.el starting loading, 
temp-global-mode=%s" 
         (if (boundp 'temp-global-mode)
             temp-global-mode
           "not boundp"))

(message "\n****** Declarations: *********")

(define-minor-mode temp-mode
  "dummy"
  :init-value nil
  :lighter nil
  :global t
  :group 'temp-test
  :initialize 'custom-initialize-set
  :set (lambda(sym val)
         (message "  temp-mode :set => sym=%s, val=%s" sym val)
         (set-default sym val))
  (message "  temp-mode body => temp-mode=%s, current-buffer=%s" temp-mode 
(current-buffer)))

(define-global-minor-mode temp-global-mode temp-mode
  (lambda()
    ;;(message "here %s" (substring (buffer-name) 0 1))
    (when (cond
           ((member (substring (buffer-name) 0 1) '(" " "*" "."))
            nil)
           (t t))
      (message "  temp-global-mode turn on called")
      (temp-mode 1)))
  :group 'temp-test
  :initialize 'custom-initialize-set
  :set (lambda(sym val)
         (message "  temp-global-mode :set => sym=%s, val=%s" sym val)
         (set-default sym val)))

(defcustom temp-defcustom nil
  "doc"
  :type 'boolean
  :group 'temp-test
  :set (lambda(sym val)
         (message "  temp-defcustom :set => sym=%s, val=%s" sym val)
         (set-default sym val)))


(message "\n****** Running tests: *********")

(message "*** (customize-set-variable 'temp-defcustom t) =>")
(customize-set-variable 'temp-defcustom t)

(message "\n*** (customize-set-variable 'temp-mode t) =>")
(customize-set-variable 'temp-mode t)
(message "*** (temp-mode 1) =>")
(temp-mode 1)

(message "\n*** (customize-set-variable 'temp-global-mode t) =>")
(temp-global-mode 1)
(message "*** (temp-global-mode 1) =>")
(customize-set-variable 'temp-global-mode t)

(message "\n<<<<<<<<< defcustom-or-minor.el loaded: temp-global-mode=%s, 
temp-mode=%s, temp-defcustom=%s\n\n"
         temp-global-mode
         temp-mode
         temp-defcustom)

reply via email to

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