emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: man/kmacro.texi


From: Luc Teirlinck
Subject: Re: man/kmacro.texi
Date: Wed, 25 Aug 2004 19:48:08 -0500 (CDT)

Richard Stallman wrote:

       Do you mean that the macro should be executed for every line
       containing at least one character in the region?  That would actually be
       bigger departure from the current behavior than what I was proposing.

   That seems reasonable to me.  What do you think is better, and why
   is it better?

The following patch implements the "at least one char in the region"
rule, with, as usual, a newline between two lines counting as part of
the previous line.

What also looks somewhat unusual is that the mark stays active after
the command in Transient Mark mode.  Is this intentional?  It could
easily be undone with a call to `deactivate-mark' at the end.  If
desired, I can install the patch below, with or without a call to
`deactivate-mark' at the end.

===File ~/macros.el-diff====================================
*** macros.el   02 Sep 2003 07:34:40 -0500      1.41
--- macros.el   25 Aug 2004 19:20:22 -0500      
***************
*** 1,6 ****
  ;;; macros.el --- non-primitive commands for keyboard macros
  
! ;; Copyright (C) 1985, 86, 87, 92, 94, 95 Free Software Foundation, Inc.
  
  ;; Maintainer: FSF
  ;; Keywords: abbrev
--- 1,6 ----
  ;;; macros.el --- non-primitive commands for keyboard macros
  
! ;; Copyright (C) 1985, 86, 87, 92, 94, 95, 04 Free Software Foundation, Inc.
  
  ;; Maintainer: FSF
  ;; Keywords: abbrev
***************
*** 240,247 ****
  
  ;;;###autoload
  (defun apply-macro-to-region-lines (top bottom &optional macro)
!   "For each complete line between point and mark, move to the beginning
! of the line, and run the last keyboard macro.
  
  When called from lisp, this function takes two arguments TOP and
  BOTTOM, describing the current region.  TOP must be before BOTTOM.
--- 240,251 ----
  
  ;;;###autoload
  (defun apply-macro-to-region-lines (top bottom &optional macro)
!   "Apply last keyboard macro to all lines in the region.
! For each line containing at least one character in the region,
! move to the beginning of the line, and run the last keyboard
! macro.  Recall that a newline is part of the line that it ends.
! Thus, if the region ends at the beginning of a line, then that
! line is not included.
  
  When called from lisp, this function takes two arguments TOP and
  BOTTOM, describing the current region.  TOP must be before BOTTOM.
***************
*** 277,310 ****
      \\C-x )
  
  and then select the region of un-tablified names and use
! `\\[apply-macro-to-region-lines]' to build the table from the names.
! "
    (interactive "r")
    (or macro
        (progn
        (if (null last-kbd-macro)
            (error "No keyboard macro has been defined"))
        (setq macro last-kbd-macro)))
!   (save-excursion
!     (let ((end-marker (progn
!                       (goto-char bottom)
!                       (beginning-of-line)
!                       (point-marker)))
!         next-line-marker)
!       (goto-char top)
!       (if (not (bolp))
!         (forward-line 1))
!       (setq next-line-marker (point-marker))
!       (while (< next-line-marker end-marker)
!       (goto-char next-line-marker)
!       (save-excursion
!         (forward-line 1)
!         (set-marker next-line-marker (point)))
!       (save-excursion
!         (let ((mark-active nil))
!           (execute-kbd-macro (or macro last-kbd-macro)))))
!       (set-marker end-marker nil)
!       (set-marker next-line-marker nil))))
  
  ;;;###autoload (define-key ctl-x-map "q" 'kbd-macro-query)
  
--- 281,312 ----
      \\C-x )
  
  and then select the region of un-tablified names and use
! `\\[apply-macro-to-region-lines]' to build the table from the names."
    (interactive "r")
    (or macro
        (progn
        (if (null last-kbd-macro)
            (error "No keyboard macro has been defined"))
        (setq macro last-kbd-macro)))
!   (when (< top bottom) 
!     (save-excursion
!       (let ((end-marker (progn
!                         (goto-char bottom)
!                         (point-marker)))
!           next-line-marker)
!       (goto-char top)
!       (forward-line 0)
!       (setq next-line-marker (point-marker))
!       (while (< next-line-marker end-marker)
!         (goto-char next-line-marker)
!         (save-excursion
!           (forward-line 1)
!           (set-marker next-line-marker (point)))
!         (save-excursion
!           (let ((mark-active nil))
!             (execute-kbd-macro (or macro last-kbd-macro)))))
!       (set-marker end-marker nil)
!       (set-marker next-line-marker nil)))))
  
  ;;;###autoload (define-key ctl-x-map "q" 'kbd-macro-query)
  
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]