XEmacs build fix
[gnus] / lisp / dgnushack.el
1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994-2014 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Version: 4.19
6 ;; Keywords: news, path
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (defvar dgnushack-default-load-path (copy-sequence load-path))
28
29 (defalias 'facep 'ignore)
30
31 (require 'cl)
32 (require 'iswitchb)
33
34 (condition-case nil
35     (require 'org-entities)
36   (error nil))
37
38 (defvar srcdir (or (getenv "srcdir") "."))
39 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
40
41 (defun my-getenv (str)
42   (let ((val (getenv str)))
43     (if (equal val "no") nil val)))
44
45 (if (my-getenv "lispdir")
46     (push (my-getenv "lispdir") load-path))
47
48 ;(push "/usr/share/emacs/site-lisp" load-path)
49
50 ;; If we are building Gnus in a different directory than the source
51 ;; directory, we must read *.el from source directory and write *.elc
52 ;; into the building directory.  For that, we define this function
53 ;; before loading bytecomp.  Bytecomp doesn't overwrite this function.
54 (defun byte-compile-dest-file (filename)
55   "Convert an Emacs Lisp source file name to a compiled file name.
56  In addition, remove directory name part from FILENAME."
57   (setq filename (byte-compiler-base-file-name filename))
58   (setq filename (file-name-sans-versions filename))
59   (setq filename (file-name-nondirectory filename))
60   (if (eq system-type 'windows-nt)
61       (setq filename (downcase filename)))
62   (cond ((eq system-type 'vax-vms)
63          (concat (substring filename 0 (string-match ";" filename)) "c"))
64         ((string-match emacs-lisp-file-regexp filename)
65          (concat (substring filename 0 (match-beginning 0)) ".elc"))
66         (t (concat filename ".elc"))))
67
68 (require 'bytecomp)
69 ;; To avoid having defsubsts and inlines happen.
70 ;(if (featurep 'xemacs)
71 ;    (require 'byte-optimize)
72 ;  (require 'byte-opt))
73 ;(defun byte-optimize-inline-handler (form)
74 ;  "byte-optimize-handler for the `inline' special-form."
75 ;  (cons 'progn (cdr form)))
76 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
77
78 ;; Work around for an incompatibility (XEmacs 21.4 vs. 21.5), see the
79 ;; following threads:
80 ;;
81 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56414
82 ;; Subject: attachment problems found but not fixed
83 ;;
84 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56459
85 ;; Subject: Splitting mail -- XEmacs 21.4 vs 21.5
86 ;;
87 ;; http://thread.gmane.org/gmane.emacs.xemacs.beta/20519
88 ;; Subject: XEmacs 21.5 and Gnus fancy splitting.
89 ;;
90 ;; Should be fixed in XEmacs (March 2007).
91 ;; http://thread.gmane.org/gmane.emacs.xemacs.patches/8124
92 ;; When should we remove this workaround?
93 ;;
94 (when (and (featurep 'xemacs)
95            (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
96              (modify-syntax-entry ?= " " table)
97              (with-temp-buffer
98                (with-syntax-table table
99                  (insert "foo=bar")
100                  (goto-char (point-min))
101                  (forward-sexp 1)
102                  (eolp)))))
103   ;; The original `with-syntax-table' uses `copy-syntax-table' which
104   ;; doesn't seem to copy modified syntax entries in old XEmacs 21.5.
105   (defmacro with-syntax-table (syntab &rest body)
106     "Evaluate BODY with the SYNTAB as the current syntax table."
107     `(let ((stab (syntax-table)))
108        (unwind-protect
109            (progn
110              ;;(set-syntax-table (copy-syntax-table ,syntab))
111              (set-syntax-table ,syntab)
112              ,@body)
113          (set-syntax-table stab)))))
114
115 (push srcdir load-path)
116 (push loaddir load-path)
117 (load (expand-file-name "lpath.el" loaddir) nil t)
118
119 (defalias 'device-sound-enabled-p 'ignore)
120 (defalias 'play-sound-file 'ignore)
121 (defalias 'efs-re-read-dir 'ignore)
122 (defalias 'ange-ftp-re-read-dir 'ignore)
123 (defalias 'define-mail-user-agent 'ignore)
124 (defalias 'debbugs-gnu-summary-mode 'ignore)
125 (defvar debbugs-gnu-bug-number nil)
126
127 (eval-and-compile
128   (unless (featurep 'xemacs)
129     (defalias 'get-popup-menu-response 'ignore)
130     (defalias 'event-object 'ignore)
131     (autoload 'iswitchb-read-buffer "iswitchb")
132     (autoload 'netrc-credentials "netrc")
133     (defalias 'x-defined-colors 'ignore)
134     (defalias 'read-color 'ignore)))
135
136 (eval-and-compile
137   (when (featurep 'xemacs)
138     (defvar window-point-insertion-type nil)
139     (unless (fboundp 'defadvice)
140       (autoload 'defadvice "advice" nil nil 'macro))
141     (unless (boundp 'help-echo-owns-message)
142       (defvar help-echo-owns-message))
143     (unless (boundp 'gnus-registry-enabled)
144       (defvar gnus-registry-enabled nil))
145     (unless (boundp 'mail-dont-reply-to-names)
146       (defvar mail-dont-reply-to-names nil))
147     (unless (fboundp 'url-retrieve-synchronously)
148       (defalias 'url-retrieve-synchronously 'url-retrieve))
149     (unless (fboundp 'url-queue-retrieve)
150       (defun url-queue-retrieve (url callback &optional cbargs silent
151                                      inhibit-cookies)
152         (url-retrieve url callback cbargs)))
153     (autoload 'Info-directory "info" nil t)
154     (autoload 'Info-index "info" nil t)
155     (autoload 'Info-index-next "info" nil t)
156     (autoload 'Info-menu "info" nil t)
157     (autoload 'ad-add-advice "advice")
158     (unless (and (emacs-version>= 21 5)
159                  (not (featurep 'sxemacs)))
160       ;; calendar/auto-autoloads.el provides it.
161       (autoload 'add-to-invisibility-spec "dummy"))
162     (autoload 'annotations-at "annotations")
163     (autoload 'apropos "apropos" nil t)
164     (autoload 'apropos-command "apropos" nil t)
165     (autoload 'bbdb-complete-name "bbdb-com" nil t)
166     (autoload 'browse-url "browse-url" nil t)
167     (autoload 'browse-url-of-file "browse-url" nil t)
168     (autoload 'c-mode "cc-mode" nil t)
169     (autoload 'customize-apropos "cus-edit" nil t)
170     (autoload 'customize-group "cus-edit" nil t)
171     (autoload 'customize-save-variable "cus-edit" nil t)
172     (autoload 'customize-set-variable "cus-edit" nil t)
173     (autoload 'customize-variable "cus-edit" nil t)
174     (autoload 'debug "debug" nil t)
175     (autoload 'sha1 "sha1")
176     (if (featurep 'mule)
177         (unless (locate-library "mule-ccl")
178           (autoload 'define-ccl-program "ccl" nil nil 'macro))
179       (defalias 'define-ccl-program 'ignore))
180     (autoload 'delete-annotation "annotations")
181     (autoload 'dolist "cl-macs" nil nil 'macro)
182     (autoload 'enriched-decode "enriched")
183     (autoload 'eudc-expand-inline "eudc" nil t)
184     (autoload 'executable-find "executable")
185     (autoload 'font-lock-fontify-buffer "font-lock" nil t)
186     (when (and (emacs-version>= 21 5)
187                (not (featurep 'sxemacs)))
188       (autoload 'get-display-table "disp-table")
189       (autoload 'put-display-table "disp-table"))
190     (autoload 'info "info" nil t)
191     (autoload 'mail-extract-address-components "mail-extr")
192     (autoload 'mail-fetch-field "mail-utils")
193     (autoload 'make-annotation "annotations")
194     (autoload 'make-display-table "disp-table")
195     (autoload 'pp "pp")
196     (autoload 'ps-despool "ps-print" nil t)
197     (autoload 'ps-spool-buffer "ps-print" nil t)
198     (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
199     (autoload 'read-passwd "passwd")
200     (autoload 'regexp-opt "regexp-opt")
201     (autoload 'reporter-submit-bug-report "reporter")
202     (if (condition-case nil
203             (progn
204               (require 'rot13)
205               (not (fboundp 'rot13-string)))
206           (error nil))
207         (defmacro rot13-string (string)
208           "Return ROT13 encryption of STRING."
209           `(let ((string ,string))
210              (with-temp-buffer
211                (insert string)
212                (translate-region (point-min) (point-max) ,rot13-display-table)
213                (buffer-string)))))
214     (if (and (emacs-version>= 21 5)
215              (not (featurep 'sxemacs)))
216         (autoload 'setenv "process" nil t)
217       (autoload 'setenv "env" nil t))
218     (autoload 'sgml-mode "psgml" nil t)
219     (autoload 'smtpmail-send-it "smtpmail")
220     (autoload 'sort-numeric-fields "sort" nil t)
221     (autoload 'sort-subr "sort")
222     (autoload 'thing-at-point "thingatpt")
223     (autoload 'toggle-truncate-lines "view-less" nil t)
224     (autoload 'trace-function-background "trace" nil t)
225     (autoload 'unmorse-region "morse" nil t)
226     (defalias 'frame-char-height 'frame-height)
227     (defalias 'frame-char-width 'frame-width)
228     (defalias 'frame-parameter 'frame-property)
229     (defalias 'make-overlay 'ignore)
230     (defalias 'overlay-end 'ignore)
231     (defalias 'overlay-get 'ignore)
232     (defalias 'overlay-put 'ignore)
233     (defalias 'overlay-start 'ignore)
234     (defalias 'overlays-in 'ignore)
235     (defalias 'replace-dehighlight 'ignore)
236     (defalias 'replace-highlight 'ignore)
237     (defalias 'gnutls-available-p 'ignore)
238     (defvar timer-list nil)
239     (defvar scroll-margin 0)))
240
241 (defun dgnushack-emacs-compile-defcustom-p ()
242   "Return non-nil if Emacs byte compiles `defcustom' forms.
243 Those Emacsen will warn against undefined variables and functions used
244 in `defcustom' forms."
245   (let ((outbuf (with-temp-buffer
246                   (insert "(defcustom foo (1+ (random)) \"\" :group 'emacs)\n")
247                   (byte-compile-from-buffer (current-buffer) "foo.el"))))
248     (when outbuf
249       (prog1
250           (with-current-buffer outbuf
251             (goto-char (point-min))
252             (search-forward " 'foo '(byte-code " nil t))
253         (kill-buffer outbuf)))))
254
255 (when (and (featurep 'xemacs)
256            (dgnushack-emacs-compile-defcustom-p))
257   (maybe-fbind '(defined-colors face-attribute))
258   (maybe-bind '(idna-program installation-directory)))
259
260 (when (featurep 'xemacs)
261   (defadvice byte-optimize-apply (before use-mapcan (form) activate)
262     "Replace (apply 'nconc (mapcar ...)) with (mapcan ...)."
263     (let ((last (nth (1- (length form)) form)))
264       (when (and (eq last (third form))
265                  (consp last)
266                  (eq 'mapcar (car last))
267                  (equal (nth 1 form) ''nconc))
268         (setq form (cons 'mapcan (cdr last)))))))
269
270 (defun dgnushack-compile-verbosely ()
271   "Call dgnushack-compile with warnings ENABLED.  If you are compiling
272 patches to gnus, you should consider modifying make.bat to call
273 dgnushack-compile-verbosely.  All other users should continue to use
274 dgnushack-compile."
275   (dgnushack-compile t))
276
277 (defun dgnushack-compile-error-on-warn ()
278   "Call dgnushack-compile with minimal warnings, but with error-on-warn ENABLED.
279 This means that every warning will be reported as an error."
280   (unless (dgnushack-compile nil t)
281     (error "Error during byte compilation (warnings were reported as errors!).")))
282
283 (defun dgnushack-compile (&optional warn error-on-warn)
284   ;;(setq byte-compile-dynamic t)
285   (unless warn
286     (setq byte-compile-warnings
287           '(free-vars unresolved callargs redefine suspicious)))
288   (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
289         (compilesuccess t)
290         ;;(byte-compile-generate-call-tree t)
291         file elc)
292     ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
293     ;; installed.
294     (when (featurep 'xemacs)
295       (setq gnus-xmas-glyph-directory "dummy"))
296     (dolist (file '(".dir-locals.el" "dgnushack.el" "lpath.el"))
297       (setq files (delete file files)))
298     (when (featurep 'base64)
299       (setq files (delete "base64.el" files)))
300     (condition-case code
301         ;; Under XEmacs 21.4 this loads easy-mmode.elc that provides
302         ;; the Emacs functions `propertize' and `replace-regexp-in-string'.
303         (require 'mh-e)
304       (error
305        (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
306        (setq files (delete "gnus-mh.el" files))))
307     (condition-case code
308         (require 'xml)
309       (error
310        (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
311        (setq files (delete "nnrss.el" files))))
312     (dolist (file
313              (if (featurep 'xemacs)
314                  '("md5.el")
315                '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
316       (setq files (delete file files)))
317     (unless (and (fboundp 'libxml-parse-html-region)
318                  ;; lpath.el binds it.
319                  (not (eq (symbol-function 'libxml-parse-html-region)
320                           'ignore)))
321       (dolist (file '("color.el"))
322         (setq files (delete file files))))
323     (unless (locate-library "epg")
324       (setq files (delete "plstore.el" files)))
325     ;; Temporary code until we fix pcase and defmethod stuff.
326     (when (or (featurep 'xemacs)
327               (or (< emacs-major-version 24)
328                   (< emacs-minor-version 3)))
329       (setq files (delete "gnus-icalendar.el" files)))
330     (dolist (file files)
331       (setq file (expand-file-name file srcdir))
332       (when (and (file-exists-p
333                   (setq elc (concat (file-name-nondirectory file) "c")))
334                  (file-newer-than-file-p file elc))
335         (delete-file elc)))
336
337     (while (setq file (pop files))
338       (setq file (expand-file-name file srcdir))
339       (when (or (not (file-exists-p
340                       (setq elc (concat (file-name-nondirectory file) "c"))))
341                 (file-newer-than-file-p file elc))
342         (if error-on-warn
343             (let ((byte-compile-error-on-warn t))
344               (unless (ignore-errors
345                         (byte-compile-file file))
346                 (setq compilesuccess nil)))
347           (ignore-errors
348             (byte-compile-file file)))))
349     compilesuccess))
350
351 (defun dgnushack-recompile ()
352   (require 'gnus)
353   (byte-recompile-directory "." 0))
354
355 (defvar dgnushack-gnus-load-file
356   (if (featurep 'xemacs)
357       (expand-file-name "auto-autoloads.el")
358     (expand-file-name "gnus-load.el")))
359
360 (defvar dgnushack-cus-load-file
361   (if (featurep 'xemacs)
362       (expand-file-name "custom-load.el")
363     (expand-file-name "cus-load.el")))
364
365 (defun dgnushack-make-cus-load ()
366   (load "cus-dep")
367   (let ((cusload-base-file dgnushack-cus-load-file))
368     (defadvice directory-files (after exclude-dir-locals activate)
369       "Exclude .dir-locals.el file."
370       (dolist (file ad-return-value)
371         (if (string-match "\\(?:\\`\\|/\\)\\.dir-locals\\.el\\'" file)
372             (setq ad-return-value (delete file ad-return-value)))))
373     (unwind-protect
374         (if (fboundp 'custom-make-dependencies)
375             (custom-make-dependencies)
376           (Custom-make-dependencies))
377       (ad-unadvise 'directory-files))
378     (when (featurep 'xemacs)
379       (message "Compiling %s..." dgnushack-cus-load-file)
380       (byte-compile-file dgnushack-cus-load-file))))
381
382 (defun dgnushack-make-auto-load ()
383   (require 'autoload)
384   (let ((generated-autoload-file dgnushack-gnus-load-file)
385         (make-backup-files nil)
386         (autoload-package-name "gnus"))
387     (if (featurep 'xemacs)
388         (if (file-exists-p generated-autoload-file)
389             (delete-file generated-autoload-file))
390       (with-temp-file generated-autoload-file
391         (insert ?\014)))
392     (defadvice directory-files (after exclude-dir-locals activate)
393       "Exclude .dir-locals.el file."
394       (dolist (file ad-return-value)
395         (if (string-match "\\(?:\\`\\|/\\)\\.dir-locals\\.el\\'" file)
396             (setq ad-return-value (delete file ad-return-value)))))
397     (unwind-protect
398         (batch-update-autoloads)
399       (ad-unadvise 'directory-files))))
400
401 (defun dgnushack-make-load ()
402   (unless (featurep 'xemacs)
403     (message "Generating %s..." dgnushack-gnus-load-file)
404     (with-temp-file dgnushack-gnus-load-file
405       (insert-file-contents dgnushack-cus-load-file)
406       (delete-file dgnushack-cus-load-file)
407       (goto-char (point-min))
408       (search-forward ";;; Code:")
409       (forward-line)
410       (delete-region (point-min) (point))
411       (insert "\
412 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
413 ;;
414 ;;; Code:
415 ")
416       (goto-char (point-max))
417       (if (search-backward "custom-versions-load-alist" nil t)
418           (forward-line -1)
419         (forward-line -1)
420         (while (eq (char-after) ?\;)
421           (forward-line -1))
422         (forward-line))
423       (delete-region (point) (point-max))
424       (insert "\n")
425       ;; smiley-* are duplicated. Remove them all.
426       (let ((point (point)))
427         (insert-file-contents dgnushack-gnus-load-file)
428         (goto-char point)
429         (while (search-forward "smiley-" nil t)
430           (beginning-of-line)
431           (if (looking-at "(autoload ")
432               (delete-region (point) (progn (forward-sexp) (point)))
433             (forward-line))))
434       ;;
435       (goto-char (point-max))
436       (when (search-backward "\n(provide " nil t)
437         (forward-line -1)
438         (delete-region (point) (point-max)))
439       (insert "\
440
441 \(provide 'gnus-load)
442
443 ;;; Local Variables:
444 ;;; version-control: never
445 ;;; no-byte-compile: t
446 ;;; no-update-autoloads: t
447 ;;; End:
448 ;;; gnus-load.el ends here
449 ")
450       ))
451   (message "Compiling %s..." dgnushack-gnus-load-file)
452   (byte-compile-file dgnushack-gnus-load-file)
453   (when (featurep 'xemacs)
454     (message "Creating dummy gnus-load.el...")
455     (with-temp-file (expand-file-name "gnus-load.el")
456       (insert "\
457
458 \(provide 'gnus-load)
459
460 ;;; Local Variables:
461 ;;; version-control: never
462 ;;; no-byte-compile: t
463 ;;; no-update-autoloads: t
464 ;;; End:
465 ;;; gnus-load.el ends here"))))
466
467 (defun dgnushack-find-lisp-shadows (&optional lispdir)
468   "Return a list of directories in which other Gnus installations exist.
469 This function looks for the other Gnus installations which will shadow
470 the new Gnus Lisp modules which have been installed in LISPDIR, using
471 the default `load-path'.  The return value will make sense only when
472 LISPDIR is existent and is listed in the default `load-path'.  Assume
473 LISPDIR will be prepended to `load-path' by a user if the default
474 `load-path' does not contain it."
475   (unless lispdir
476     (setq lispdir (getenv "lispdir")))
477   (when (and lispdir (file-directory-p lispdir))
478     (setq lispdir (file-truename (directory-file-name lispdir)))
479     (let ((indices '("gnus.elc" "gnus.el" "gnus.el.bz2" "gnus.el.gz"
480                      "message.elc" "message.el" "message.el.bz2"
481                      "message.el.gz"))
482           (path (delq nil (mapcar
483                            (lambda (p)
484                              (condition-case nil
485                                  (when (and p (file-directory-p p))
486                                    (file-truename (directory-file-name p)))
487                                (error nil)))
488                            dgnushack-default-load-path)))
489           rest elcs)
490       (while path
491         (setq rest (cons (car path) rest)
492               path (delete (car rest) (cdr path))))
493       (setq path (nreverse (cdr (member lispdir rest)))
494             rest nil)
495       (while path
496         (setq elcs indices)
497         (while elcs
498           (when (file-exists-p (expand-file-name (pop elcs) (car path)))
499             (setq rest (cons (car path) rest)
500                   elcs nil)))
501         (setq path (cdr path)))
502       (prog1
503           (setq path (nreverse rest))
504         (when path
505           (let (print-level print-length)
506             (princ (concat "\n\
507 WARNING: The other Gnus installation" (if (cdr path) "s have" " has") "\
508  been detected in:\n\n  " (mapconcat 'identity path "\n  ") "\n\n\
509 You will need to modify the run-time `load-path', remove them manually,
510 or remove them using `make remove-installed-shadows'.\n\n"))))))))
511
512 (defun dgnushack-remove-lisp-shadows (&optional lispdir)
513   "Remove the other Gnus installations which shadow the recent one."
514   (let ((path (with-temp-buffer
515                 (let ((standard-output (current-buffer)))
516                   (dgnushack-find-lisp-shadows lispdir))))
517         elcs files shadows file)
518     (when path
519       (unless (setq elcs (directory-files srcdir nil "\\.elc\\'"))
520         (error "You should build .elc files first."))
521       (setq files
522             (apply
523              'append
524              (mapcar
525               (lambda (el)
526                 (list (concat el "c") el (concat el ".bz2") (concat el ".gz")))
527               (append
528                (list (file-name-nondirectory dgnushack-gnus-load-file)
529                      (file-name-nondirectory dgnushack-cus-load-file))
530                (mapcar (lambda (elc) (substring elc 0 -1)) elcs)))))
531       (while path
532         (setq shadows files)
533         (while shadows
534           (setq file (expand-file-name (pop shadows) (car path)))
535           (when (file-exists-p file)
536             (princ (concat "  Removing " file "..."))
537             (condition-case nil
538                 (progn
539                   (delete-file file)
540                   (princ "done\n"))
541               (error (princ "failed\n")))))
542         (setq path (cdr path))))))
543
544 (unless (fboundp 'with-demoted-errors)
545   (defmacro with-demoted-errors (&rest body)
546     "Run BODY and demote any errors to simple messages.
547 If `debug-on-error' is non-nil, run BODY without catching its errors.
548 This is to be used around code which is not expected to signal an error
549 but which should be robust in the unexpected case that an error is signaled."
550     (declare (debug t) (indent 0))
551     (let ((err (make-symbol "err")))
552       `(condition-case ,err
553            (progn ,@body)
554          (error (message "Error: %S" ,err) nil)))))
555
556 ;; XEmacs's `define-obsolete-variable-alias' takes only two arguments:
557 ;; (define-obsolete-variable-alias OLDVAR NEWVAR)
558 (condition-case nil
559     (progn
560       (defvar dgnushack-obsolete-name nil)
561       (defvar dgnushack-current-name nil)
562       (unwind-protect
563           (define-obsolete-variable-alias
564             'dgnushack-obsolete-name 'dgnushack-current-name "0")
565         (makunbound 'dgnushack-obsolete-name)
566         (makunbound 'dgnushack-current-name)))
567   (wrong-number-of-arguments
568    (defadvice define-obsolete-variable-alias (around ignore-rest-args
569                                                      (oldvar newvar &rest args)
570                                                      activate)
571      "Ignore arguments other than the 1st and the 2nd ones."
572      ad-do-it)
573    (put 'define-obsolete-variable-alias 'byte-optimizer
574         (lambda (form)
575           (setcdr (nthcdr 2 form) nil)
576           form))))
577
578 ;;; dgnushack.el ends here