comparison lisp/emulation/viper-cmd.el @ 20003:9bc6a4017c8c

new version
author Michael Kifer <kifer@cs.stonybrook.edu>
date Tue, 30 Sep 1997 01:13:53 +0000
parents 9a4cdbf423ea
children 4327dd36b71b
comparison
equal deleted inserted replaced
20002:e89847e2df84 20003:9bc6a4017c8c
1812 corresponding file exists is selected. If no file exists for any of the 1812 corresponding file exists is selected. If no file exists for any of the
1813 suffixes, the user is asked to confirm. 1813 suffixes, the user is asked to confirm.
1814 1814
1815 To turn this feature off, set this variable to nil." 1815 To turn this feature off, set this variable to nil."
1816 :type '(repeat string) 1816 :type '(repeat string)
1817 :group 'viper) 1817 :group 'viper-misc)
1818 1818
1819 1819
1820 ;; Try to add a suitable suffix to files whose name ends with a `.' 1820 ;; Try to add a suitable suffix to files whose name ends with a `.'
1821 ;; Useful when the user hits RET on a non-completed file name. 1821 ;; Useful when the user hits RET on a non-completed file name.
1822 ;; Used as a minibuffer exit hook in read-file-name 1822 ;; Used as a minibuffer exit hook in read-file-name
3228 ;; sentence ,paragraph and heading 3228 ;; sentence ,paragraph and heading
3229 3229
3230 (defun viper-forward-sentence (arg) 3230 (defun viper-forward-sentence (arg)
3231 "Forward sentence." 3231 "Forward sentence."
3232 (interactive "P") 3232 (interactive "P")
3233 (push-mark nil t) 3233 (or (eq last-command this-command)
3234 (push-mark nil t))
3234 (let ((val (viper-p-val arg)) 3235 (let ((val (viper-p-val arg))
3235 (com (viper-getcom arg))) 3236 (com (viper-getcom arg)))
3236 (if com (viper-move-marker-locally 'viper-com-point (point))) 3237 (if com (viper-move-marker-locally 'viper-com-point (point)))
3237 (forward-sentence val) 3238 (forward-sentence val)
3238 (if com (viper-execute-com 'viper-forward-sentence nil com)))) 3239 (if com (viper-execute-com 'viper-forward-sentence nil com))))
3239 3240
3240 (defun viper-backward-sentence (arg) 3241 (defun viper-backward-sentence (arg)
3241 "Backward sentence." 3242 "Backward sentence."
3242 (interactive "P") 3243 (interactive "P")
3243 (push-mark nil t) 3244 (or (eq last-command this-command)
3245 (push-mark nil t))
3244 (let ((val (viper-p-val arg)) 3246 (let ((val (viper-p-val arg))
3245 (com (viper-getcom arg))) 3247 (com (viper-getcom arg)))
3246 (if com (viper-move-marker-locally 'viper-com-point (point))) 3248 (if com (viper-move-marker-locally 'viper-com-point (point)))
3247 (backward-sentence val) 3249 (backward-sentence val)
3248 (if com (viper-execute-com 'viper-backward-sentence nil com)))) 3250 (if com (viper-execute-com 'viper-backward-sentence nil com))))
3249 3251
3250 (defun viper-forward-paragraph (arg) 3252 (defun viper-forward-paragraph (arg)
3251 "Forward paragraph." 3253 "Forward paragraph."
3252 (interactive "P") 3254 (interactive "P")
3253 (push-mark nil t) 3255 (or (eq last-command this-command)
3256 (push-mark nil t))
3254 (let ((val (viper-p-val arg)) 3257 (let ((val (viper-p-val arg))
3255 (com (viper-getCom arg))) 3258 (com (viper-getCom arg)))
3256 (if com (viper-move-marker-locally 'viper-com-point (point))) 3259 (if com (viper-move-marker-locally 'viper-com-point (point)))
3257 (forward-paragraph val) 3260 (forward-paragraph val)
3258 (if com 3261 (if com
3261 (viper-execute-com 'viper-forward-paragraph nil com))))) 3264 (viper-execute-com 'viper-forward-paragraph nil com)))))
3262 3265
3263 (defun viper-backward-paragraph (arg) 3266 (defun viper-backward-paragraph (arg)
3264 "Backward paragraph." 3267 "Backward paragraph."
3265 (interactive "P") 3268 (interactive "P")
3266 (push-mark nil t) 3269 (or (eq last-command this-command)
3270 (push-mark nil t))
3267 (let ((val (viper-p-val arg)) 3271 (let ((val (viper-p-val arg))
3268 (com (viper-getCom arg))) 3272 (com (viper-getCom arg)))
3269 (if com (viper-move-marker-locally 'viper-com-point (point))) 3273 (if com (viper-move-marker-locally 'viper-com-point (point)))
3270 (backward-paragraph val) 3274 (backward-paragraph val)
3271 (if com 3275 (if com
3272 (progn 3276 (progn
3273 (forward-char 1) 3277 (forward-char 1)
3274 (viper-execute-com 'viper-backward-paragraph nil com) 3278 (viper-execute-com 'viper-backward-paragraph nil com)
3275 (backward-char 1))))) 3279 (backward-char 1)))))
3276 3280
3277 ;; should be mode-specific etc. 3281 ;; should be mode-specific
3278
3279 (defun viper-prev-heading (arg) 3282 (defun viper-prev-heading (arg)
3280 (interactive "P") 3283 (interactive "P")
3281 (let ((val (viper-p-val arg)) 3284 (let ((val (viper-p-val arg))
3282 (com (viper-getCom arg))) 3285 (com (viper-getCom arg)))
3283 (if com (viper-move-marker-locally 'viper-com-point (point))) 3286 (if com (viper-move-marker-locally 'viper-com-point (point)))
4286 (let ((reg (read-char))) 4289 (let ((reg (read-char)))
4287 (cond ((viper-valid-register reg '(letter Letter)) 4290 (cond ((viper-valid-register reg '(letter Letter))
4288 (view-register (downcase reg))) 4291 (view-register (downcase reg)))
4289 ((viper-valid-register reg '(digit)) 4292 ((viper-valid-register reg '(digit))
4290 (let ((text (current-kill (- reg ?1) 'do-not-rotate))) 4293 (let ((text (current-kill (- reg ?1) 'do-not-rotate)))
4291 (save-excursion 4294 (with-output-to-temp-buffer " *viper-info*"
4292 (set-buffer (get-buffer-create "*Output*")) 4295 (princ (format "Register %c contains the string:\n" reg))
4293 (delete-region (point-min) (point-max)) 4296 (princ text))
4294 (insert (format "Register %c contains the string:\n" reg)) 4297 ))
4295 (insert text)
4296 (goto-char (point-min)))
4297 (display-buffer "*Output*")))
4298 ((= ?\] reg) 4298 ((= ?\] reg)
4299 (viper-next-heading arg)) 4299 (viper-next-heading arg))
4300 (t (error 4300 (t (error
4301 viper-InvalidRegister reg))))) 4301 viper-InvalidRegister reg)))))
4302 4302
4308 (viper-prev-heading arg)) 4308 (viper-prev-heading arg))
4309 ((= ?\] reg) 4309 ((= ?\] reg)
4310 (viper-heading-end arg)) 4310 (viper-heading-end arg))
4311 ((viper-valid-register reg '(letter)) 4311 ((viper-valid-register reg '(letter))
4312 (let* ((val (get-register (1+ (- reg ?a)))) 4312 (let* ((val (get-register (1+ (- reg ?a))))
4313 (buf (if (not val) 4313 (buf (if (not (markerp val))
4314 (error viper-EmptyTextmarker reg) 4314 (error viper-EmptyTextmarker reg)
4315 (marker-buffer val))) 4315 (marker-buffer val)))
4316 (pos (marker-position val)) 4316 (pos (marker-position val))
4317 line-no text (s pos) (e pos)) 4317 line-no text (s pos) (e pos))
4318 (save-excursion 4318 (with-output-to-temp-buffer " *viper-info*"
4319 (set-buffer (get-buffer-create "*Output*"))
4320 (delete-region (point-min) (point-max))
4321 (if (and buf pos) 4319 (if (and buf pos)
4322 (progn 4320 (progn
4323 (save-excursion 4321 (save-excursion
4324 (set-buffer buf) 4322 (set-buffer buf)
4325 (setq line-no (1+ (count-lines (point-min) val))) 4323 (setq line-no (1+ (count-lines (point-min) val)))
4337 (setq e (point)))) 4335 (setq e (point))))
4338 (setq text (buffer-substring s e)) 4336 (setq text (buffer-substring s e))
4339 (setq text (format "%s<%c>%s" 4337 (setq text (format "%s<%c>%s"
4340 (substring text 0 (- pos s)) 4338 (substring text 0 (- pos s))
4341 reg (substring text (- pos s))))) 4339 reg (substring text (- pos s)))))
4342 (insert 4340 (princ
4343 (format 4341 (format
4344 "Textmarker `%c' is in buffer `%s' at line %d.\n" 4342 "Textmarker `%c' is in buffer `%s' at line %d.\n"
4345 reg (buffer-name buf) line-no)) 4343 reg (buffer-name buf) line-no))
4346 (insert (format "Here is some text around %c:\n\n %s" 4344 (princ (format "Here is some text around %c:\n\n %s"
4347 reg text))) 4345 reg text)))
4348 (insert (format viper-EmptyTextmarker reg))) 4346 (princ (format viper-EmptyTextmarker reg))))
4349 (goto-char (point-min))) 4347 ))
4350 (display-buffer "*Output*")))
4351 (t (error viper-InvalidTextmarker reg))))) 4348 (t (error viper-InvalidTextmarker reg)))))
4352 4349
4353 4350
4354 4351
4355 ;; commands in insertion mode 4352 ;; commands in insertion mode