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