 (require 'ffap)
 (require 'url)
 
+;; XEmacs compatibility guidelines
+;; - Minimum required version of XEmacs: 21.5.32
+;;   - Feature that cannot be backported: POSIX character classes in
+;;     regular expressions
+;;   - Functions that could be backported but won't because 21.5.32
+;;     covers them: plenty.
+;;   - Features that are still partly broken:
+;;     - godef will not work correctly if multibyte characters are
+;;       being used
+;;     - Fontification will not handle unicode correctly
+;;
+;; - Do not use \_< and \_> regexp delimiters directly; use
+;;   go--regexp-enclose-in-symbol
+;;
+;; - The character `_` must not be a symbol constituent but a
+;;   character constituent
+;;
+;; - Do not use process-lines
+;;
+;; - Use go--old-completion-list-style when using a plain list as the
+;;   collection for completing-read
+;;
+;; - Use go--kill-whole-line instead of kill-whole-line (called
+;;   kill-entire-line in XEmacs)
+;;
+;; - Use go--position-bytes instead of position-bytes
 (defmacro go--xemacs-p ()
   `(featurep 'xemacs))
 
-;; XEmacs added syntax-ppss in version 21.5.32. For older versions, we
-;; have to use parse-partial-sexp, which will be slightly slower due
-;; to the lack of caching.
-(if (fboundp 'syntax-ppss)
-    (defmacro go--syntax-ppss ()
-      `(syntax-ppss))
-  (defmacro go--syntax-ppss ()
-    `(parse-partial-sexp (point-min) (point))))
+(defalias 'go--kill-whole-line
+  (if (fboundp
+       'kill-whole-line)
+      'kill-whole-line 'kill-entire-line))
+
+;; XEmacs unfortunately does not offer position-bytes. We can fall
+;; back to just using (point), but it will be incorrect as soon as
+;; multibyte characters are being used.
+(if (fboundp 'position-bytes)
+    (defalias 'go--position-bytes 'position-bytes)
+  (defun go--position-bytes (point) point))
+
+(defun go--old-completion-list-style (list)
+  (mapcar (lambda (x) (cons x nil)) list))
+
 
 (defun go--regexp-enclose-in-symbol (s)
   ;; XEmacs does not support \_<, GNU Emacs does. In GNU Emacs we make

                (goto-char (point-min))
                (forward-line (- from line-offset 1))
                (incf line-offset len)
                (kill-whole-line len)))
             (t
              (error "invalid rcs patch or internal error in go--apply-rcs-patch")))))))))


          (beginning-of-line)
          (if arg
              (comment-region (line-beginning-position) (line-end-position))
            (go--kill-whole-line)))
        (message "Removed %d imports" (length lines)))
      (if flymake-state (flymake-mode-on)))))

