auth.texi (GnuPG and EasyPG Assistant Configuration): Be agnostic about authinfo...
[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 (unless (fboundp 'declare-function)
30   (defmacro declare-function (&rest r)))
31
32 (defalias 'facep 'ignore)
33
34 (require 'cl)
35 (require 'iswitchb)
36
37 (condition-case nil
38     (require 'org-entities)
39   (error nil))
40
41 (defvar srcdir (or (getenv "srcdir") "."))
42 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
43
44 (defun my-getenv (str)
45   (let ((val (getenv str)))
46     (if (equal val "no") nil val)))
47
48 (if (my-getenv "lispdir")
49     (push (my-getenv "lispdir") load-path))
50
51 ;(push "/usr/share/emacs/site-lisp" load-path)
52
53 ;; If we are building Gnus in a different directory than the source
54 ;; directory, we must read *.el from source directory and write *.elc
55 ;; into the building directory.  For that, we define this function
56 ;; before loading bytecomp.  Bytecomp doesn't overwrite this function.
57 (defun byte-compile-dest-file (filename)
58   "Convert an Emacs Lisp source file name to a compiled file name.
59  In addition, remove directory name part from FILENAME."
60   (setq filename (byte-compiler-base-file-name filename))
61   (setq filename (file-name-sans-versions filename))
62   (setq filename (file-name-nondirectory filename))
63   (if (eq system-type 'windows-nt)
64       (setq filename (downcase filename)))
65   (cond ((eq system-type 'vax-vms)
66          (concat (substring filename 0 (string-match ";" filename)) "c"))
67         ((string-match emacs-lisp-file-regexp filename)
68          (concat (substring filename 0 (match-beginning 0)) ".elc"))
69         (t (concat filename ".elc"))))
70
71 (require 'bytecomp)
72 ;; To avoid having defsubsts and inlines happen.
73 ;(if (featurep 'xemacs)
74 ;    (require 'byte-optimize)
75 ;  (require 'byte-opt))
76 ;(defun byte-optimize-inline-handler (form)
77 ;  "byte-optimize-handler for the `inline' special-form."
78 ;  (cons 'progn (cdr form)))
79 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
80
81 ;; Work around for an incompatibility (XEmacs 21.4 vs. 21.5), see the
82 ;; following threads:
83 ;;
84 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56414
85 ;; Subject: attachment problems found but not fixed
86 ;;
87 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56459
88 ;; Subject: Splitting mail -- XEmacs 21.4 vs 21.5
89 ;;
90 ;; http://thread.gmane.org/gmane.emacs.xemacs.beta/20519
91 ;; Subject: XEmacs 21.5 and Gnus fancy splitting.
92 ;;
93 ;; Should be fixed in XEmacs (March 2007).
94 ;; http://thread.gmane.org/gmane.emacs.xemacs.patches/8124
95 ;; When should we remove this workaround?
96 ;;
97 (when (and (featurep 'xemacs)
98            (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
99              (modify-syntax-entry ?= " " table)
100              (with-temp-buffer
101                (with-syntax-table table
102                  (insert "foo=bar")
103                  (goto-char (point-min))
104                  (forward-sexp 1)
105                  (eolp)))))
106   ;; The original `with-syntax-table' uses `copy-syntax-table' which
107   ;; doesn't seem to copy modified syntax entries in old XEmacs 21.5.
108   (defmacro with-syntax-table (syntab &rest body)
109     "Evaluate BODY with the SYNTAB as the current syntax table."
110     `(let ((stab (syntax-table)))
111        (unwind-protect
112            (progn
113              ;;(set-syntax-table (copy-syntax-table ,syntab))
114              (set-syntax-table ,syntab)
115              ,@body)
116          (set-syntax-table stab)))))
117
118 (push srcdir load-path)
119 (push loaddir load-path)
120 (load (expand-file-name "lpath.el" loaddir) nil t)