[Top][All Lists]

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

mud/moo emacs (RE: command loop untouchable; ARGGHHH!)

From: Karl Chen
Subject: mud/moo emacs (RE: command loop untouchable; ARGGHHH!)
Date: Sat, 24 Aug 2002 02:02:03 -0700 (PDT)

   It is my desire that all text except the text at the end of the buffer
   be immune to tampering via keyboard.  The protection doesn't have to be
   strong; I just don't want keystrokes that alter the buffer to have any
   effect when typed while the cursor is in the "history" section of the

You're on the right track with keymaps. The way I finally solved this
problem in the emacs mud mode I was working myself on was by using a local
map with text properties.

Use this function:

;;; this is `copy-region-as-kill'
(defun mud-copy-region-no-properties-as-kill (beg end)
  "Save the region without properties as if killed, but don't kill it.
In Transient Mark mode, deactivate the mark.
If `interprogram-cut-function' is non-nil, also save the text for a window
system cut and paste."
  (interactive "r")
  (if (eq last-command 'kill-region)
      (kill-append (buffer-substring-no-properties beg end) (< end beg))
    (kill-new (buffer-substring-no-properties beg end)))
  (if transient-mark-mode
      (setq deactivate-mark t))

(Note to emacs developers: this function is generic and might be useful to
add to emacs itself)

Create a local keymap and substitute copy-region-as-kill, etc with this
function. Then copied text will lose properties. I like this for removing
colors as well but you can modify the function to only lose certain

You could have all these functions compare against a marker for whether
you're in the "input" or "output" (history) portion of the buffer, but I
think it is better to use a text-property of local-map for the output

Thus you can use read-only, but this is even more useful (in addition):
use substitute-key-definition to change functions such as self-insert-char
and yank to functions that "go" to the insertion point (end of buffer
probably) and repeat the action there. You can do other stuff with
text-properties such as fields so that point movement functions stay
within or out of your "history" region.

Attached is my own kc-mud.el which is not at all polished but I felt it
was "really cool dude" back when I cared about mud (which thankfully was
only a few months). Feel free to look at it for ideas. It's got some nifty
features like different operating modes for different numbers of buffers,
local aliases, custom regexp hooks, etc.

Karl Chen / address@hidden

Attachment: kc-mud.el
Description: Text document

Attachment: x-mud-settings.el
Description: Text document

reply via email to

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