Download
(defgroup doi nil
"Do Or Insert."
:group 'editing)
(defcustom doi-insert-function 'doi-insert-default
"The insert function for `doi'.
It accepts one prefix argument for insert.
Default is `doi-insert-default'."
:type 'function
:group 'doi)
(defun doi-scroll-up (&optional arg)
"Do `doi' with `scroll-up'.
ARG is prefix argument."
(interactive "p")
(doi 'scroll-up arg))
(defun doi-scroll-down (&optional arg)
"Do `doi' with `scroll-down'.
ARG is prefix argument."
(interactive "p")
(doi 'scroll-down arg))
(defun doi-scroll-up-one-line (&optional arg)
"Do `doi' with `scroll-up', but just one line.
ARG is prefix argument."
(interactive "p")
(doi '(lambda ()
(scroll-up 1))
arg))
(defun doi-scroll-down-one-line (&optional arg)
"Do `doi' with `scroll-down', but just one line.
ARG is prefix argument."
(interactive "p")
(doi '(lambda ()
(scroll-down 1))
arg))
(defun doi-previous-line (&optional arg)
"Do `doi' with `previous-line'.
ARG is prefix argument."
(interactive "p")
(doi 'previous-line arg))
(defun doi-next-line (&optional arg)
"Do `doi' with `next-line'.
ARG is prefix argument."
(interactive "p")
(doi 'next-line arg))
(defun doi-backward-char (&optional arg)
"Do `doi' with `backward-char'.
ARG is prefix argument."
(interactive "p")
(doi 'backward-char arg))
(defun doi-forward-char (&optional arg)
"Do `doi' with `forward-char'.
ARG is prefix argument."
(interactive "p")
(doi 'forward-char arg))
(defun doi-backward-word (&optional arg)
"Do `doi' with `backward-word'.
ARG is prefix argument."
(interactive "p")
(doi 'backward-word arg))
(defun doi-forward-word (&optional arg)
"Do `doi' with `forward-word'.
ARG is prefix argument."
(interactive "p")
(doi 'forward-word arg))
(defun doi-isearch-forward (&optional arg)
"Do `doi' with `isearch-forward'.
ARG is prefix argument."
(interactive "p")
(doi 'isearch-forward arg))
(defun doi-isearch-backward (&optional arg)
"Do `doi' with `isearch-backward'.
ARG is prefix argument."
(interactive "p")
(doi 'isearch-backward arg))
(defun doi-move-beginning-of-line (&optional arg)
"Do `doi' with `move-beginning-of-line'.
ARG is prefix argument."
(interactive "p")
(doi '(lambda ()
(call-interactively 'move-beginning-of-line)) arg))
(defun doi-move-end-of-line (&optional arg)
"Do `doi' with `move-end-of-line'.
ARG is prefix argument."
(interactive "p")
(doi '(lambda ()
(call-interactively 'move-end-of-line)) arg))
(defun doi-beginning-of-buffer (&optional arg)
"Do `doi' with `beginning-of-buffer'.
ARG is prefix argument."
(interactive "p")
(doi 'beginning-of-buffer arg))
(defun doi-end-of-buffer (&optional arg)
"Do `doi' with `end-of-buffer'.
ARG is prefix argument."
(interactive "p")
(doi 'end-of-buffer arg))
(defun doi (command &optional arg)
"Do Or Insert.
If cursor is at `text-read-only' area do COMMAND,
otherwise insert self.
ARG is prefix argument."
(condition-case nil
(funcall doi-insert-function arg)
(text-read-only
(funcall command))))
(defun doi-insert-default (arg)
"The default insert function for `doi'.
ARG is prefix argument."
(if (and (require 'completion-ui nil t)
(member 'auto-completion-mode minor-mode-list))
(completion-self-insert)
(self-insert-command (or arg 1))))
(provide 'doi)