[Top][All Lists]

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

revert-chars (snippet)

From: Andreas Roehler
Subject: revert-chars (snippet)
Date: Thu, 28 May 2009 10:15:40 +0200
User-agent: Thunderbird (X11/20081227)

a thing I need quite often...

;; (global-set-key [(control kp-9)] 'revert-chars)

(defun revert-chars ()
  "Revert reciproke chars as \"[\" to \"]\", upcase or downcase. "
  (interactive "*")
  (let* ((cf (char-after))
         (cn (downcase cf)))
    (cond ((or (eq cf 62)(eq cf ?\>))
           (setq cn "<"))
          ((or (eq cf 60)(eq cf ?\<))
           (setq cn ">"))
          ((or (eq cf 40)(eq cf ?\())
           (setq cn ")"))
          ((or (eq cf 41)(eq cf ?\)))
           (setq cn "("))
          ((or (eq cf 123) (eq cf ?\{))
           (setq cn "}"))
          ((or (eq cf 125) (eq cf ?\}))
           (setq cn "{"))
          ((or (eq cf 93)(eq cf ?\]))
           (setq cn "["))
          ((or (eq cf 91)(eq cf ?\[))
           (setq cn "]"))
          ((or (eq cf 45)(eq cf ?\-))
           (setq cn "_"))
          ((or (eq cf 95)(eq cf ?\_))
           (setq cn "-"))
          (t (when (eq cf cn)
               (setq cn (upcase cf)))))
    (delete-char 1)
    (insert cn)))

This function may be changed, extended and/or commented at


Andreas Röhler


reply via email to

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