Patch by Balint Reczey <balint@balintreczey.hu> fixes backquote
syntax (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=494823).
Also, it fixes manpage name regexp matching only 3erl manpages in
section 3.

--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -497,8 +497,8 @@
 (defvar erlang-man-dirs
   '(("Man - Commands" "/man/man1" t)
     ("Man - Modules" "/man/man3" t)
-    ("Man - Files" "/man/man4" t)
-    ("Man - Applications" "/man/man6" t))
+    ("Man - Files" "/man/man5" t)
+    ("Man - Applications" "/man/man7" t))
   "*The man directories displayed in the Erlang menu.
 
 Each item in the list should be a list with three elements, the first
@@ -1285,23 +1285,22 @@
 (or (fboundp 'eval-when-compile)
     (defmacro eval-when-compile (&rest rest) nil))
 
-;; These umm...functions are new in Emacs 20. And, yes, until version
-;; 19.27 Emacs backquotes were this ugly.
+;; These umm...functions are new in Emacs 20.
 
 (or (fboundp 'unless)
     (defmacro unless (condition &rest body)
       "(unless CONDITION BODY...): If CONDITION is false, do BODY, else return nil."
-      `((if (, condition) nil ,@body))))
+      (cons 'if  (cons condition (cons nil body)))))
 
 (or (fboundp 'when)
     (defmacro when (condition &rest body)
       "(when CONDITION BODY...): If CONDITION is true, do BODY, else return nil."
-      `((if (, condition) (progn ,@body) nil))))
+      (list 'if condition (cons 'progn body) nil)))
 
 (or (fboundp 'char-before)
     (defmacro char-before (&optional pos)
       "Return the character in the current buffer just before POS."
-      `( (char-after (1- (or ,pos (point)))))))
+      (list 'char-after (list '1- (list 'or  pos '(point))))))
 
 ;; defvar some obsolete variables, which we still support for
 ;; backwards compatibility reasons.
@@ -2024,7 +2023,7 @@
 
 (defun erlang-man-make-menu-item (file)
   "Create a menu item containing the name of the man page."
-  (and (string-match ".+/\\([^/]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file)
+  (and (string-match ".+/\\([^/]+\\)\\.\\([124-9]\\|3\\(erl\\)\\)\\(\\.gz\\)?$" file)
        (let ((page (substring file (match-beginning 1) (match-end 1))))
 	 (list (capitalize page)
 	       (list 'lambda '()
@@ -2035,7 +2034,7 @@
 
 (defun erlang-man-get-files (dir)
   "Return files in directory DIR."
-  (directory-files dir t ".+\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?\\'"))
+  (directory-files dir t ".+\\.\\([124-9]\\|3\\(erl\\)\\)\\(\\.gz\\)?\\'"))
 
 
 (defun erlang-man-module (&optional module)
@@ -2055,7 +2054,7 @@
   (if (or (null module) (string= module ""))
       (error "No Erlang module name given"))
   (let ((dir-list erlang-man-dirs)
-	(pat (concat "/" (regexp-quote module) "\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$"))
+	(pat (concat "/" (regexp-quote module) "\\.\\([124-9]\\|3\\(erl\\)\\)\\(\\.gz\\)?$"))
 	(file nil)
 	file-list)
     (while (and dir-list (null file))
@@ -2196,9 +2195,9 @@
     (error nil))
   (if file
       (let ((process-environment (copy-sequence process-environment)))
-	(if (string-match "\\(.*\\)/man[^/]*/\\([^.]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file)
+	(if (string-match "\\(.*\\)/man[^/]*/\\([^.]+\\)\\.\\([124-9]\\|3\\(erl\\)\\)\\(\\.gz\\)?$" file)
 	    (let ((dir (substring file (match-beginning 1) (match-end 1)))
-		  (page (substring file (match-beginning 2) (match-end 2))))
+		  (page (concat (substring file (match-beginning 2) (match-end 2)) "(" (substring file (match-beginning 3) (match-end 3)) ")")))
 	      (if (fboundp 'setenv)
 		  (setenv "MANPATH" dir)
 		;; Emacs 18
