emacs-devel
[Top][All Lists]
Advanced

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

Re: Evil defvars in org.el


From: Achim Gratz
Subject: Re: Evil defvars in org.el
Date: Sat, 28 Apr 2012 07:57:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Stefan Monnier writes:
> While I strongly support fixing such things, do note that since those
> cases are very common, the lexical-binding code had to find a way to
> avoid this mess.

It would certainly be a good idea if the Elisp manual said something
about this.

>  So in reality in Emacs-24 such (defvar <foo>) only
> affect the current file (actually only the current scope, so you can do
> (defun test () (defvar toto) (let (toto ...) ...)) and `toto' will only
> be dynbound within `test'.

I had no idea this is even possible... and the manual advises that the
defvar should "usually be at top-level".  So, commenting out all the
file-level (defvar date) in all of org and then changing in org-bbdb.el
like this:

--8<---------------cut here---------------start------------->8---
(defun org-bbdb-anniversaries()
  "Extract anniversaries from BBDB for display in the agenda."
  (with-no-warnings (defvar date)) ;; dynamically scoped from calendar
  (require 'bbdb)
  (require 'diary-lib)
  (unless (hash-table-p org-bbdb-anniv-hash)
    (setq org-bbdb-anniv-hash
          (make-hash-table :test 'equal :size 366)))

  (when (or org-bbdb-updated-p
            (= 0 (hash-table-count org-bbdb-anniv-hash)))
    (org-bbdb-make-anniv-hash))

  (let* ((m (car date))    ; month
         (d (nth 1 date))  ; day
         (y (nth 2 date))  ; year
         (annivs (gethash (list m d) org-bbdb-anniv-hash))
         (text ())
         rec recs)
--8<---------------cut here---------------end--------------->8---

should create a dynamic binding that exists only within the scope of
org-bbdb-anniversary, is that right?  Could it possibly leak into other
scopes due to the (require ...) present?  I still have to supress the
warning due to unprefixed "date", should this warning automatically be
suppressed in this idiom?


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf Blofeld V1.15B11:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada




reply via email to

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