From: Ed Sinjiashvili Date: 2002-06-10T14:49:50+09:00 Subject: Re: ruby-mode.el - zmacs regions friendly --=-=-= matz@ruby-lang.org (Yukihiro Matsumoto) writes: > Hi, > > In message "ruby-mode.el - zmacs regions friendly" > on 02/06/07, Ed Sinjiashvili writes: > > |A tiny patch to make ruby-mode.el aware of zmacs regions. > > This breaks ruby-mode on plain Emacs. What does these "_" mean? From xemacs (documentation 'interactive): ---- If the string begins with `_', then this command will not cause the region to be deactivated when it completes; that is, `zmacs-region-stays' will be set to t when the command exits successfully. ---- I'm sorry, I didn't know GNU Emacs lacks zmacs regions. Without that "_" movement by blocks in XEmacs is quite crippled (there's no transient mark mode in XEmacs AFAIK). Maybe we could use macros to deal with that emacsen discrepancies. I attach (ugly) patch to demonstrate this approach. I tested it with both XEmacs 21.1.14 and GNU Emacs 20.7.1. -- Ed --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=t Content-Description: patch --- ruby-mode.el~ Mon Jun 10 09:28:44 2002 +++ ruby-mode.el Mon Jun 10 09:24:46 2002 @@ -6,6 +6,14 @@ ;;; created at: Fri Feb 4 14:49:13 JST 1994 ;;; +(defmacro XEmacs-interactive-hack (DEFUN) + (when (string-match "XEmacs" (version)) + (let ((int-form (fifth DEFUN))) + (if (null (cdr int-form)) + (setcdr int-form (cons "_" nil)) + (setcdr int-form (cons (concat "_" (cadr int-form)) nil))))) + DEFUN) + (defconst ruby-mode-revision "$Revision: 1.25.2.3 $") (defconst ruby-mode-version @@ -569,6 +577,7 @@ (self-insert-command (prefix-numeric-value arg)) (ruby-indent-line t)) +(XEmacs-interactive-hack (defun ruby-beginning-of-defun (&optional arg) "Move backward to next beginning-of-defun. With argument, do this that many times. @@ -576,7 +585,7 @@ (interactive "p") (and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\b") nil 'move (or arg 1)) - (progn (beginning-of-line) t))) + (progn (beginning-of-line) t)))) (defun ruby-beginning-of-indent () (and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\b") @@ -585,6 +594,7 @@ (beginning-of-line) t))) +(XEmacs-interactive-hack (defun ruby-end-of-defun (&optional arg) "Move forward to next end of defun. An end of a defun is found by moving forward from the beginning of one." @@ -592,7 +602,7 @@ (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\($\\|\\b[^_]\\)") nil 'move (or arg 1)) (progn (beginning-of-line) t)) - (forward-line 1)) + (forward-line 1))) (defun ruby-move-to-block (n) (let (start pos done down) @@ -620,15 +630,17 @@ (setq done nil))))))) (back-to-indentation)) -(defun ruby-beginning-of-block () - "Move backward to next beginning-of-block" - (interactive) - (ruby-move-to-block -1)) - -(defun ruby-end-of-block () - "Move forward to next beginning-of-block" - (interactive) - (ruby-move-to-block 1)) +(XEmacs-interactive-hack + (defun ruby-beginning-of-block () + "Move backward to next beginning-of-block" + (interactive) + (ruby-move-to-block -1))) + +(XEmacs-interactive-hack + (defun ruby-end-of-block () + "Move forward to next beginning-of-block" + (interactive) + (ruby-move-to-block 1))) (defun ruby-reindent-then-newline-and-indent () (interactive "*") --=-=-=--