Emacs Part 42
■ このスレッドは過去ログ倉庫に格納されています
0281名無しさん@お腹いっぱい。
2013/01/31(木) 09:29:08.46これで完璧だろう>>267.こういうときはコンマセパレートでいいのかね.
(defun hyper-sequential-rotate-force (cycle start end &rest args)
"Rotate a number of strings. In interactive call, specify more
than one string separated by comma. If you specify three strings
A, B and C, rotate A->B and B->C. If CYCLE is non-nil (prefix arg
in interactive call), rotate A->B, B->C and C->A.
In Transient Mark mode, if the mark is active, operate on the contents
of the region. Otherwise, operate from point to the end of the buffer."
(interactive
`(,current-prefix-arg
,(and (use-region-p) (region-beginning))
,(and (use-region-p) (region-end))
,@(split-string (read-string "Strings (seprated by comma): ") ",")))
(when (< (length args) 2)
(error "Specify more than two strings"))
(let* ((len (length args))
(from-string (mapconcat
(lambda (x)
(format"\\(%s\\)" x))
(if cycle args (butlast args)) "\\|"))
(condition (mapcar
(lambda (x)
`((match-end ,(- len (mod (length (member x args)) len))) ,x))
args)))
(perform-replace from-string
`(replace-eval-replacement replace-quote (cond ,@condition))
t t nil nil nil start end)))
■ このスレッドは過去ログ倉庫に格納されています