Here are improvements to the Prolog major mode for Emacs. Typically these patches are incorporated into the official version with some delay. Currently not yet included are the changes implemented by this patch.

To obtain PceEmacs-like behaviour and use the mode with SWI-Prolog, add to your .emacs:
    (setq prolog-system 'swi
          prolog-program-switches '((swi ("-G128M" "-T128M" "-L128M" "-O"))
                                    (t nil))
          prolog-electric-if-then-else-flag t)
    
In addition, I recommend:
      (setq prolog-indent-width 4
            prolog-electric-dot-flag t
            prolog-electric-dash-flag t
            prolog-electric-colon-flag t)
    

prolog-electric-dot-flag: Electric dot appends newline or inserts head of a new clause. If dot is pressed at the end of a line where at least one white space precedes the point, it inserts a recursive call to the current predicate. If dot is pressed at the beginning of an empty line, it inserts the head of a new clause for the current predicate.


Add the following to insert a comment block with C-c C-q, as in PceEmacs:
        (defun prolog-insert-comment-block ()
          (interactive)
          (insert "/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */")
          (forward-line -1)
          (indent-for-tab-command))

        (global-set-key "\C-c\C-q" 'prolog-insert-comment-block)
    


Since Emacs (-snapshot) version >= 22, flymake ships with Emacs. This enables on-the-fly syntax checking, using the Prolog compiler as checker. To use it with SWI-Prolog, add the following to your .emacs:
     (add-hook 'prolog-mode-hook
               (lambda ()
                 (require 'flymake)
                 (make-local-variable 'flymake-allowed-file-name-masks)
                 (make-local-variable 'flymake-err-line-patterns)
                 (setq flymake-err-line-patterns
                       '(("ERROR: (?\\(.*?\\):\\([0-9]+\\)" 1 2)
                         ("Warning: (\\(.*\\):\\([0-9]+\\)" 1 2)))
                 (setq flymake-allowed-file-name-masks
                       '(("\\.pl\\'" flymake-prolog-init)))
                 (flymake-mode 1)))

     (defun flymake-prolog-init ()
       (let* ((temp-file   (flymake-init-create-temp-buffer-copy
                            'flymake-create-temp-inplace))
              (local-file  (file-relative-name
                            temp-file
                            (file-name-directory buffer-file-name))))
         (list "pl" (list "-q" "-t" "halt" "-s " local-file))))
    


Main page