(require 'easymenu)
(require 'align)
+(eval-when-compile
+ (or (fboundp 'use-region-p)
+ (defsubst use-region-p () (region-exists-p))))
(defgroup prolog nil
"Editing and running Prolog and Mercury files."
;; prolog buffer)
;;-------------------------------------------------------------------
-(unless (fboundp 'region-exists-p)
- (defun region-exists-p ()
- "Non-nil if the mark is set. Lobotomized version for Emacsen that do not provide their own."
- (mark)))
-
-
;; GNU Emacs ignores `easy-menu-add' so the order in which the menus
;; are defined _is_ important!
:included (not (eq prolog-system 'mercury))]
["Consult buffer" prolog-consult-buffer
:included (not (eq prolog-system 'mercury))]
- ["Consult region" prolog-consult-region :active (region-exists-p)
+ ["Consult region" prolog-consult-region :active (use-region-p)
:included (not (eq prolog-system 'mercury))]
["Consult predicate" prolog-consult-predicate
:included (not (eq prolog-system 'mercury))]
:included (eq prolog-system 'sicstus)]
["Compile buffer" prolog-compile-buffer
:included (eq prolog-system 'sicstus)]
- ["Compile region" prolog-compile-region :active (region-exists-p)
+ ["Compile region" prolog-compile-region :active (use-region-p)
:included (eq prolog-system 'sicstus)]
["Compile predicate" prolog-compile-predicate
:included (eq prolog-system 'sicstus)]
prolog-edit-menu-insert-move prolog-mode-map
"Commands for Prolog code manipulation."
'("Prolog"
- ["Comment region" comment-region (region-exists-p)]
- ["Uncomment region" prolog-uncomment-region (region-exists-p)]
+ ["Comment region" comment-region (use-region-p)]
+ ["Uncomment region" prolog-uncomment-region (use-region-p)]
["Add comment/move to comment" indent-for-comment t]
["Convert variables in region to '_'" prolog-variables-to-anonymous
- :active (region-exists-p) :included (not (eq prolog-system 'mercury))]
+ :active (use-region-p) :included (not (eq prolog-system 'mercury))]
"---"
["Insert predicate template" prolog-insert-predicate-template t]
["Insert next clause head" prolog-insert-next-clause t]
["End of predicate" prolog-end-of-predicate t]
"---"
["Indent line" indent-according-to-mode t]
- ["Indent region" indent-region (region-exists-p)]
+ ["Indent region" indent-region (use-region-p)]
["Indent predicate" prolog-indent-predicate t]
["Indent buffer" prolog-indent-buffer t]
- ["Align region" align (region-exists-p)]
+ ["Align region" align (use-region-p)]
"---"
["Mark clause" prolog-mark-clause t]
["Mark predicate" prolog-mark-predicate t]