-;; XEmacs change
-(defvar lisp-interaction-mode-popup-menu nil)
-(defvar lisp-interaction-mode-popup-menu-1
- (purecopy '("Lisp-Interaction"
- ["Evaluate Last S-expression" eval-last-sexp]
- ["Evaluate Entire Buffer" eval-current-buffer]
- ["Evaluate Region" eval-region
- :active (region-exists-p)]
- "---"
- ["Evaluate This Defun" eval-defun]
- ;; FSF says "Instrument Function for Debugging"
- ["Debug This Defun" edebug-defun]
- "---"
- ["Trace a Function" trace-function-background]
- ["Untrace All Functions" untrace-all
- :active (fboundp 'untrace-all)]
- "---"
- ["Comment Out Region" comment-region
- :active (region-exists-p)]
- ["Indent Region" indent-region
- :active (region-exists-p)]
- ["Indent Line" lisp-indent-line]
- "---"
- ["Debug On Error" (setq debug-on-error (not debug-on-error))
- :style toggle :selected debug-on-error]
- ["Debug On Quit" (setq debug-on-quit (not debug-on-quit))
- :style toggle :selected debug-on-quit]
- ["Debug on Signal" (setq debug-on-signal (not debug-on-signal))
- :style toggle :selected debug-on-signal]
- )))
-
-(defvar emacs-lisp-mode-popup-menu nil)
-(defvar emacs-lisp-mode-popup-menu-1
- (purecopy
- (nconc
- '("Emacs-Lisp"
- ["Byte-compile This File" emacs-lisp-byte-compile]
- ["Byte-compile/load This" emacs-lisp-byte-compile-and-load]
- ["Byte-recompile Directory..." byte-recompile-directory]
- "---")
- (cdr lisp-interaction-mode-popup-menu-1))))
+(defun construct-lisp-mode-menu (popup-p emacs-lisp-p)
+ (flet ((popup-wrap (form)
+ (if popup-p `(menu-call-at-event ',form) form)))
+ `(,@(if emacs-lisp-p
+ `(["%_Byte-Compile This File" ,(popup-wrap
+ 'emacs-lisp-byte-compile)]
+ ["B%_yte-Compile/Load This File"
+ ,(popup-wrap 'emacs-lisp-byte-compile-and-load)]
+ ["Byte-%_Recompile Directory..."
+ ,(popup-wrap 'byte-recompile-directory)]
+ "---"))
+ ["%_Evaluate Region or Defun"
+ ,(popup-wrap '(if (region-exists-p)
+ (call-interactively 'eval-region)
+ (call-interactively 'eval-defun)))]
+ ["Evaluate %_Whole Buffer" ,(popup-wrap 'eval-current-buffer)]
+ ["Evaluate Last %_S-expression" ,(popup-wrap 'eval-last-sexp)]
+ "---"
+ ,@(if popup-p
+ '(["%_Find Function"
+ (find-function (menu-call-at-event '(function-at-point)))
+ :suffix (let ((fun (menu-call-at-event '(function-at-point))))
+ (if fun (symbol-name fun) ""))
+ :active (and (fboundp 'find-function)
+ (menu-call-at-event '(function-at-point)))]
+ ["%_Find Variable"
+ (find-variable (menu-call-at-event '(variable-at-point)))
+ :suffix (let ((fun (menu-call-at-event '(variable-at-point))))
+ (if fun (symbol-name fun) ""))
+ :active (and (fboundp 'find-variable)
+ (menu-call-at-event '(variable-at-point)))]
+ ["%_Help on Function"
+ (describe-function (menu-call-at-event '(function-at-point)))
+ :suffix (let ((fun (menu-call-at-event '(function-at-point))))
+ (if fun (symbol-name fun) ""))
+ :active (and (fboundp 'describe-function)
+ (menu-call-at-event '(function-at-point)))]
+ ["%_Help on Variable"
+ (describe-variable (menu-call-at-event '(variable-at-point)))
+ :suffix (let ((fun (menu-call-at-event '(variable-at-point))))
+ (if fun (symbol-name fun) ""))
+ :active (and (fboundp 'describe-variable)
+ (menu-call-at-event '(variable-at-point)))])
+ '(["Find %_Function..." find-function
+ :active (fboundp 'find-function)]
+ ["Find %_Variable..." find-variable
+ :active (fboundp 'find-variable)]
+ ["%_Help on Function..." describe-function
+ :active (fboundp 'describe-function)]
+ ["Hel%_p on Variable..." describe-variable
+ :active (fboundp 'describe-variable)]))
+ "---"
+ ["Instrument This Defun for %_Debugging" ,(popup-wrap 'edebug-defun)]
+ ["%_Trace Function..." trace-function-background]
+ ["%_Untrace All Functions" untrace-all
+ :active (fboundp 'untrace-all)]
+ "---"
+ ["%_Comment Out Region" comment-region :active (region-exists-p)]
+ "---"
+ ["%_Indent Region or Balanced Expression"
+ ,(popup-wrap '(if (region-exists-p)
+ (call-interactively 'indent-region)
+ (call-interactively 'indent-sexp)))]
+ ["I%_ndent Defun"
+ ,(popup-wrap '(progn
+ (beginning-of-defun)
+ (indent-sexp)))]
+ "---"
+ "Look for debug-on-error under Options->Troubleshooting"
+ )))
+
+(defvar lisp-interaction-mode-popup-menu
+ (cons "Lisp-Interaction" (construct-lisp-mode-menu t nil)))
+
+(defvar emacs-lisp-mode-popup-menu
+ (cons "Emacs-Lisp" (construct-lisp-mode-menu t t)))