* sh-script beg-end of command
@ 2007-11-22 8:10 Andreas Röhler
2007-11-22 12:13 ` Andreas Röhler
2007-11-22 16:23 ` Richard Stallman
0 siblings, 2 replies; 4+ messages in thread
From: Andreas Röhler @ 2007-11-22 8:10 UTC (permalink / raw)
To: emacs-devel
Hi all,
let's consider behaviour of `sh-end-of-command' with
this peace of code from install.sh
M-e stops at
while [ x"$1" != x ]; do
________________________|___
case $1 in
______________|___________
-c) instcmd="$cpprog"
__________|__________________
shift
_________________|___________
continue;;
____________________|_________
First both stops seem ok, third not, fifth at least
questionable.
Try M-e and M-a from the very beginning of the script
to and fro: IMO stops are nearly not predictable.
Changed behaviour to that
M-a stops at beginnings
and M-e at ends
of separated lines of code,
skipping comments and empty lines and single closing braces.
Below der code, any comments welcome.
Thanks
Andreas Röhler
;;; sh-beg-end-of-command.el --- Something useful for
;;; M-a and M-e in sh-script
;; Copyright (C) 2007 Andreas Röhler
;; Author: Andreas Röhler <andreas.roehler@online.de>
;; Keywords: languages
;; This file is free software; you can redistribute it
;; and/or modify it under the terms of the GNU General
;; Public License as published by the Free Software
;; Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the
;; implied warranty of MERCHANTABILITY or FITNESS FOR A
;; PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General
;; Public License along with GNU Emacs; see the file
;; COPYING. If not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Jumps to the beginning or end of command in a given
;; line, forward or backward next beginning or end with
;; repeated execution. With argument doing this as many
;; times.
;;; Code:
(require 'newcomment.el)
(defun sh-beginning-of-command (&optional arg)
"Move point to successive beginnings of commands."
(interactive "p")
(let ((arg (or arg 1)))
(while (< 0 arg)
(forward-line (- arg))
(setq arg (1- arg))
;; skip comments and empty lines and closing braces
(while (or (empty-line-p)
(looking-at (concat "^[ \t]*" comment-start))
(looking-at "}"))
(forward-line -1))
(back-to-indentation)
;; an indented comment may be followed by empty lines
(while (or (empty-line-p)
(looking-at (concat "^[ \t]*" comment-start))
(looking-at "}"))
(forward-line -1))
(back-to-indentation))))
(defun sh-end-of-command (&optional arg)
"Move point to successive ends of commands."
(interactive "p")
(let ((arg (or arg 1))
(pos (point)))
(end-of-line)
(skip-chars-backward " \t\r\n\f" (line-beginning-position))
(unless (eq pos (point))
;; point has moved
(setq arg (1- arg)))
(while (< 0 arg)
(forward-line arg)
(setq arg (1- arg)))
(end-of-line)
(skip-chars-backward " \t\r\n\f" (line-beginning-position))
(while (or
(empty-line-p)
(save-excursion
(and
(re-search-backward (concat "^[ \t]*" comment-start)
(line-beginning-position) t 1)
(not (looking-back "[[:alnum:]]\\{2,\\}.*"
(line-beginning-position))))))
(forward-line 1)
(end-of-line))
(skip-chars-backward " \t\r\n\f")
(when (and
(re-search-backward (concat "^[ \t]*" comment-start)
(line-beginning-position) t 1)
(looking-back "[[:alnum:]]\\{2,\\}.*" (line-beginning-position)))
(skip-chars-backward " \t\r\n\f"))))
(provide 'sh-beg-end-of-command)
;;; sh-beg-end-of-command.el ends here
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sh-script beg-end of command
2007-11-22 8:10 sh-script beg-end of command Andreas Röhler
@ 2007-11-22 12:13 ` Andreas Röhler
2007-11-22 16:23 ` Richard Stallman
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2007-11-22 12:13 UTC (permalink / raw)
To: emacs-devel
(require 'newcomment) not (require 'newcomment.el)
Sorry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sh-script beg-end of command
2007-11-22 8:10 sh-script beg-end of command Andreas Röhler
2007-11-22 12:13 ` Andreas Röhler
@ 2007-11-22 16:23 ` Richard Stallman
2007-11-24 15:23 ` Andreas Röhler
1 sibling, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2007-11-22 16:23 UTC (permalink / raw)
To: emacs-devel; +Cc: Andreas Röhler
Would people please study this and report?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sh-script beg-end of command
2007-11-22 16:23 ` Richard Stallman
@ 2007-11-24 15:23 ` Andreas Röhler
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2007-11-24 15:23 UTC (permalink / raw)
To: rms; +Cc: emacs-devel
Am Donnerstag, 22. November 2007 17:23 schrieb Richard Stallman:
> Would people please study this and report?
>
>
This is rewritten, merged and published with
sh-beg-end.el in gun-emacs-sources
Thanks
Andreas Röhler
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-24 15:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-22 8:10 sh-script beg-end of command Andreas Röhler
2007-11-22 12:13 ` Andreas Röhler
2007-11-22 16:23 ` Richard Stallman
2007-11-24 15:23 ` Andreas Röhler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.