Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Various fixes for Emacs 21.

Ignore-this: caae466ff29882fa42f44e081d0a8909

darcs-hash:20091105211507-d4134-9760a383d1bd0d15501d223cbf334798f59ed80d.gz
  • Loading branch information...
commit 748ee94d214582b9616a3a4e0a5b6c5cdba3335b 1 parent b9769ec
@loveshack loveshack authored
View
5 README
@@ -25,6 +25,11 @@ Otherwise:
- Download and unpack the basic mode and modules into a suitable directory,
e.g. ~/lib/emacs/haskell-mode/ where ~ stands for your home directory.
+- If you are using Emacs 21, you need an additional library, "syntax", from
+ a later version of Emacs. The one you can get as
+ http://cvs.savannah.gnu.org/viewcvs/*checkout*/emacs/emacs/lisp/emacs-lisp/syntax.el?rev=1.16
+ definitely works.
+
- Assuming you have placed the basic mode haskell-mode.el and the modules
you want to use in the directory ~/lib/emacs/haskell-mode/, add the
following command to your init file (~/.emacs):
View
1  haskell-cabal.el
@@ -124,6 +124,7 @@
(setq root nil))))
nil)))
+(autoload 'derived-mode-p "derived") ; Emacs 21
(defun haskell-cabal-buffers-clean (&optional buffer)
(let ((bufs ()))
View
23 haskell-decl-scan.el
@@ -128,6 +128,7 @@
;;; Code:
(require 'haskell-mode)
+(require 'syntax nil t) ; Emacs 21 add-on
;;###autoload
;; As `cl' defines macros that `imenu' uses, we must require them at
@@ -136,7 +137,27 @@
(require 'cl)
(condition-case nil
(require 'imenu)
- (error nil)))
+ (error nil))
+ ;; It makes a big difference if we don't copy the syntax table here,
+ ;; as Emacs 21 does, but Emacs 22 doesn't.
+ (unless (eq (syntax-table)
+ (with-syntax-table (syntax-table) (syntax-table)))
+ (defmacro with-syntax-table (table &rest body)
+ "Evaluate BODY with syntax table of current buffer set to a copy of TABLE.
+The syntax table of the current buffer is saved, BODY is evaluated, and the
+saved table is restored, even in case of an abnormal exit.
+Value is what BODY returns."
+ (let ((old-table (make-symbol "table"))
+ (old-buffer (make-symbol "buffer")))
+ `(let ((,old-table (syntax-table))
+ (,old-buffer (current-buffer)))
+ (unwind-protect
+ (progn
+ (set-syntax-table ,table)
+ ,@body)
+ (save-current-buffer
+ (set-buffer ,old-buffer)
+ (set-syntax-table ,old-table))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General declaration scanning functions.
View
37 haskell-doc.el
@@ -535,6 +535,37 @@ Each element is of the form (ID . DOC) where both ID and DOC are strings.
DOC should be a concise single-line string describing the construct in which
the keyword is used.")
+(eval-and-compile
+(defalias 'haskell-doc-split-string
+ (if (condition-case ()
+ (split-string "" nil t)
+ (wrong-number-of-arguments nil))
+ 'split-string
+ ;; copied from Emacs 22
+ (lambda (string &optional separators omit-nulls)
+ (let ((keep-nulls (not (if separators omit-nulls t)))
+ (rexp (or separators "[ \f\t\n\r\v]+"))
+ (start 0)
+ notfirst
+ (list nil))
+ (while (and (string-match rexp string
+ (if (and notfirst
+ (= start (match-beginning 0))
+ (< start (length string)))
+ (1+ start) start))
+ (< start (length string)))
+ (setq notfirst t)
+ (if (or keep-nulls (< start (match-beginning 0)))
+ (setq list
+ (cons (substring string start (match-beginning 0))
+ list)))
+ (setq start (match-end 0)))
+ (if (or keep-nulls (< start (length string)))
+ (setq list
+ (cons (substring string start)
+ list)))
+ (nreverse list))))))
+
;;@cindex haskell-doc-prelude-types
(defun haskell-doc-extract-types (url)
@@ -648,7 +679,7 @@ the keyword is used.")
;; module vars)
nil)
(setq curclass nil))
- (dolist (var (split-string vars comma-re t))
+ (dolist (var (haskell-doc-split-string vars comma-re t))
(if (string-match "(.*)" var) (setq var (substring var 1 -1)))
(push (cons var type) elems))))
;; A datatype decl.
@@ -669,7 +700,7 @@ the keyword is used.")
(if (string-match ",\\'" type)
(setq type (substring type 0 -1)))
(setq type (concat name " -> " type))
- (dolist (var (split-string vars comma-re t))
+ (dolist (var (haskell-doc-split-string vars comma-re t))
(if (string-match "(.*)" var)
(setq var (substring var 1 -1)))
(push (cons var type) elems))))))))
@@ -1516,6 +1547,8 @@ function. Only the user interface is different."
;;@cindex haskell-doc-show-type
+(require 'syntax-ppss nil t) ; possible add-on in Emacs 21
+
(defun haskell-doc-in-code-p ()
(not (or (and (eq haskell-literate 'bird)
;; Copied from haskell-indent-bolp.
View
9 haskell-font-lock.el
@@ -230,13 +230,20 @@ Regexp match data 0 points to the chars."
;; Return nil because we're not adding any face property.
nil)
+(unless (fboundp 'char-displayable-p)
+ (require 'latin1-disp nil t))
+
(defun haskell-font-lock-symbols-keywords ()
(when (fboundp 'compose-region)
(let ((alist nil))
(dolist (x haskell-font-lock-symbols-alist)
(when (and (if (fboundp 'char-displayable-p)
(char-displayable-p (if (consp (cdr x)) (cadr x) (cdr x)))
- t)
+ (if (fboundp 'latin1-char-displayable-p)
+ (latin1-char-displayable-p (if (consp (cdr x))
+ (cadr x)
+ (cdr x)))
+ t))
(not (assoc (car x) alist))) ;Not yet in alist.
(push x alist)))
(when alist
View
4 haskell-indentation.el
@@ -35,6 +35,8 @@
;;; Code:
+(require 'syntax nil t) ; Emacs 21 add-on
+
(defgroup haskell-indentation nil
"Haskell indentation."
:group 'haskell
@@ -265,7 +267,7 @@ Preserves indentation and removes extra whitespace"
(haskell-indentation-next-indentation
-1
(haskell-indentation-find-indentations))))
- ((not (eql (point) haskell-indent-last-position))
+ ((not (equal (point) haskell-indent-last-position))
(message "Press TAB again to go to the leftmost indentation")
(setq haskell-indent-last-position (point)))
(t
View
17 haskell-mode.el
@@ -158,6 +158,13 @@
;;; Code:
(eval-when-compile (require 'cl))
+(eval-when-compile
+ ;; Emacs 21 defines `values' as a (run-time) alias for list.
+ ;; Don't maerge this with the pervious clause.
+ (if (string-match "values"
+ (pp (byte-compile (lambda () (values t)))))
+ (defsubst values (&rest values)
+ values)))
;; All functions/variables start with `(literate-)haskell-'.
@@ -385,8 +392,14 @@ May return a qualified name."
"Hook run after entering Haskell mode.
Do not select more than one of the three indentation modes."
:type 'hook
- :options '(turn-on-haskell-indent turn-on-haskell-indentation turn-on-font-lock turn-on-eldoc-mode
- turn-on-simple-indent turn-on-haskell-doc-mode imenu-add-menubar-index))
+ :group 'haskell
+ :options `(turn-on-haskell-indent turn-on-haskell-indentation
+ turn-on-font-lock
+ ,(if (boundp 'eldoc-documentation-function)
+ 'turn-on-eldoc-mode
+ 'turn-on-haskell-doc-mode) ; Emacs 21
+ turn-on-simple-indent turn-on-haskell-doc-mode
+ imenu-add-menubar-index))
(defvar eldoc-print-current-symbol-info-function)
Please sign in to comment.
Something went wrong with that request. Please try again.