unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Lennart Borgman" <lennart.borgman@gmail.com>
To: "Alan Mackenzie" <acm@muc.de>
Cc: help-gnu-emacs@gnu.org, Paul R <paul.r.ml@gmail.com>
Subject: Re: emacs-w3m question
Date: Sat, 8 Nov 2008 02:14:15 +0100	[thread overview]
Message-ID: <e01d8a50811071714p169688bds86bd0bdb3266dc4e@mail.gmail.com> (raw)
In-Reply-To: <20081107235156.GC2707@muc.de>

[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]

On Sat, Nov 8, 2008 at 12:51 AM, Alan Mackenzie <acm@muc.de> wrote:
> My part solution is to have several default Emacs "personalities" - or
> perhaps better called "Emacsicalities" - perhaps 2 or 3 of them.  Each
> one would be implemented by a Lisp file setting certain defaults.  So,
> the "CUA Emacsicality" would enable cua-mode, and maybe one or two other
> things, "Classic Emacsicality" would leave all settings at their
> optimum-for-experts.  The startup screen would prompt the user to chose
> his desired Emacsicality, but would at the same time encourage her to
> switch to "classic" for the ultimate experience.  Obviously, you'd set
> some sort of option for this after the first 2 or 3 times.
>
> However, like everything else in Emacs, good ideas only happen when the
> person with the idea implements it.  Maybe I should try this once Emacs
> 23's been released.

Have no fear, you are not alone on this road. May friends be with you!

(I think I might have sent this to Emacs devel once, not sure.)

[-- Attachment #2: rebind.el --]
[-- Type: text/plain, Size: 7096 bytes --]

;;; rebind.el --- Rebind keys
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2008-01-20T12:04:37+0100 Sun
;; Version:
;; Last-Updated:
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;;   None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; See `rebind-keys-mode' for information.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(require 'new-key-seq-widget)


(defun rebind-toggle-first-modifier (orig-key-seq mod)
  (let* ((first (elt orig-key-seq 0))
         (new-key-seq (copy-sequence orig-key-seq)))
    (setq first (if (memq mod first)
                    (delq mod first)
                  (cons mod first)))
    (aset new-key-seq 0 first)
    new-key-seq))
;; (rebind-toggle-first-modifier (key-description-to-vector "C-c a") 'shift)
;; (rebind-toggle-first-modifier (key-description-to-vector "C-S-c a") 'shift)

(defconst rebind-keys-mode-map (make-sparse-keymap))

(defun rebind-update-keymap (symbol value)
  ;(lwarn t :warning "value=%S" value)
  (let ((m (make-sparse-keymap)))
    (dolist (group value)
      ;(lwarn t :warning "group=%S" group)
      (when (nth 1 group)
        (dolist (v (nth 2 group))
          (let* (
                 (orig-key   (nth 0 v))
                 (comment    (nth 1 v))
                 (enabled    (nth 2 v))
                 (new-choice (nth 3 v))
                 (new-fun    (nth 4 v))
                 (orig-fun (lookup-key global-map orig-key))
                 new-key)
            (when new-choice
              (if (memq new-choice '(meta control shift))
                  (setq new-key (rebind-toggle-first-modifier orig-key new-choice))
                (setq new-key new-choice))
              (define-key m new-key orig-fun))
            (when enabled
              (define-key m orig-key new-fun))))
        (setq rebind-keys-mode-map m))
      (set-default symbol value))))

(defvar widget-commandp-prompt-value-history nil)

(define-widget 'command 'function
  "A major mode lisp function."
  :complete-function (lambda ()
                       (interactive)
                       (lisp-complete-symbol 'commandp))
  :prompt-match 'major-modep
  :prompt-history 'widget-commandp-prompt-value-history
  :match-alternatives '(commandp)
  :validate (lambda (widget)
              (unless (major-modep (widget-value widget))
                (widget-put widget :error (format "Invalid function: %S"
                                                  (widget-value widget)))
                widget))
  :value 'fundamental-mode
  :tag "Command function")

;; (customize-option 'rebind-keys)
(defcustom rebind-keys
  ;; (Fetched key bindings from http://www.davidco.com/tips_tools/tip45.html)
  '(
    ("MS Windows - often used key bindings" t
      (
       (
        [(control ?a)]
        "C-a on w32 normally means 'select all'. In Emacs it is `beginning-of-line'."
        t
        shift
        mark-whole-buffer)
      (
       [(control ?o)]
       "C-o on w32 normally means 'open file'. In Emacs it is `open-line'."
       nil
       shift
       find-file)
      (
       [(control ?f)]
       "C-f is commonly search on w32. In Emacs it is `forward-char'."
       nil
       shift
       isearch-forward)
      (
       [(control ?s)]
       "C-s is normally 'save file' on w32. In Emacs it is `isearch-forward'."
       nil
       nil
       save-buffer)
      (
       [(control ?w)]
       "C-w is often something like kill-buffer on w32. In Emacs it is `kill-region'."
       t
       shift
       kill-buffer)
      (
       [(control ?p)]
       "C-p is nearly always print on w32. In Emacs it is `previous-line'."
       t
       shift
       hfyview-buffer)
       )))
  "Normal Emacs keys that are remapped to follow some other standard.
The purpose of this variable is to make it easy to switch between
Emacs key bindings and other standards.

The new bindings is made in the global minor mode
`rebind-keys-mode' and will only have effect when this mode is
on.

You can only move functions bound in the global key map this way."
  :type '(repeat
          (list
           (string :tag "For what")
           (boolean :tag "Group on/off")
           (repeat
            (list
             (key-sequence :tag "Emacs key binding")
             (string :tag "Why rebind")
             (boolean :tag "Rebinding on/off")
             (choice :tag "Move original by"
                     (const :tag "Don't put it on any new binding" nil)
                     (choice :tag "Add key binding modifier"
                             (const meta)
                             (const control)
                             (const shift))
                     (key-sequence :tag "New binding for original function"))
             (command :tag "New command on above key"))
            )))
  :set 'rebind-update-keymap
  :group 'emacsw32
  )

(defconst rebind--emul-keymap-alist (list (cons 'rebind-keys-mode rebind-keys-mode-map)))

(defun rebind-keys-post-command ()
  "Make sure we are first in the list when turned on.
This is reasonable since we are using this mode to really get the
key bindings we want!"
  (setq emulation-mode-map-alists (delq 'rebind--emul-keymap-alist emulation-mode-map-alists))
  (when rebind-keys-mode
    (add-to-list 'emulation-mode-map-alists 'rebind--emul-keymap-alist)))

(define-minor-mode rebind-keys-mode
  "Rebind keys as defined in `rebind-keys'.
The key bindings will override almost all other key bindings."
  :keymap rebind-keys-mode-map
  :global t
  (if rebind-keys-mode
      (add-hook 'post-command-hook 'rebind-keys-post-command)
    (remove-hook 'post-command-hook 'rebind-keys-post-command)
    (setq emulation-mode-map-alists (delq 'rebind--emul-keymap-alist emulation-mode-map-alists))))


(provide 'rebind)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; rebind.el ends here

  reply	other threads:[~2008-11-08  1:14 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-27 20:45 emacs-w3m question Francis Moreau
2008-10-27 21:09 ` henry atting
2008-10-27 21:36   ` Richard Riley
2008-10-28 18:40     ` Xah
2008-10-30 21:25       ` Xavier Maillard
2008-10-30 22:16         ` Paul R
2008-11-01  7:25           ` Xavier Maillard
2008-11-01 12:59             ` Paul R
     [not found]           ` <mailman.2625.1225539334.25473.help-gnu-emacs@gnu.org>
2008-11-01 15:51             ` Richard Riley
2008-11-03 11:25               ` Xavier Maillard
2008-11-03 12:13                 ` Richard Riley
2008-11-03 23:25                   ` Xavier Maillard
     [not found]                   ` <mailman.2907.1225862955.25473.help-gnu-emacs@gnu.org>
2008-11-05 13:23                     ` Xah
     [not found]       ` <mailman.2522.1225402310.25473.help-gnu-emacs@gnu.org>
2008-10-30 22:38         ` Xah
2008-11-03 11:25           ` Xavier Maillard
2008-11-03 12:36             ` Paul R
2008-11-03 23:25               ` Xavier Maillard
     [not found]             ` <mailman.2772.1225715774.25473.help-gnu-emacs@gnu.org>
2008-11-03 13:27               ` Richard Riley
2008-11-04 13:19                 ` Chris McMahan
2008-11-04 14:19                   ` Richard Riley
2008-11-05  7:25                   ` Xavier Maillard
     [not found]           ` <mailman.2764.1225711684.25473.help-gnu-emacs@gnu.org>
     [not found]             ` <4d476218-bd76-4d41-8a12-1428dfba9e9b@s9g2000prg.googlegroups.com>
2008-11-05  7:25               ` Xavier Maillard
     [not found]               ` <mailman.2966.1225952942.25473.help-gnu-emacs@gnu.org>
2008-11-06 14:31                 ` Xah
2008-11-06 16:32                   ` Alan Mackenzie
2008-11-06 18:12                   ` Giorgos Keramidas
2008-11-07  1:22                     ` Xah
2008-11-07  3:50                       ` Giorgos Keramidas
2008-11-07  5:42                         ` Xah
2008-11-07  7:48                           ` Giorgos Keramidas
2008-11-07  8:07                             ` Xah
     [not found]                   ` <mailman.3000.1225988502.25473.help-gnu-emacs@gnu.org>
2008-11-07  1:01                     ` Xah
2008-11-07 10:04                       ` Alan Mackenzie
2008-11-07 10:29                         ` Paul R
2008-11-07 23:51                           ` Alan Mackenzie
2008-11-08  1:14                             ` Lennart Borgman [this message]
2008-11-10 21:25                           ` Xavier Maillard
2008-11-10 21:25                         ` Xavier Maillard
     [not found]                       ` <mailman.3052.1226051600.25473.help-gnu-emacs@gnu.org>
2008-11-07 17:43                         ` Xah
2008-11-08 14:36                           ` Is there anyway to save workspace so that we don't have reopen 10s of files again ? Maindoor
2008-11-08 14:56                             ` Eli Zaretskii
2008-11-08 15:09                               ` Maindoor
2008-11-08 16:11                                 ` Peter Dyballa
2008-11-08 18:24                                 ` Saving registers (was: Is there anyway to save workspace so that we don't have reopen 10s of files again ?) Reiner Steib
2008-11-08 22:25                                 ` Is there anyway to save workspace so that we don't have reopen 10s of files again ? Juanma Barranquero
2008-11-06 18:02               ` emacs-w3m question Alan Mackenzie
2008-11-07  6:24                 ` Kevin Rodgers
     [not found]               ` <mailman.3010.1225993912.25473.help-gnu-emacs@gnu.org>
2008-11-06 20:02                 ` Rupert Swarbrick
2008-11-07  2:02                 ` Xah
2008-11-07 10:24                   ` Eli Zaretskii
2008-11-07 10:54                   ` Alan Mackenzie
     [not found]                   ` <mailman.3055.1226054611.25473.help-gnu-emacs@gnu.org>
2008-11-07 20:10                     ` Xah
2008-11-07 20:12                     ` How to make friends. [was emacs-w3m question] Xah
2008-11-07 20:17                     ` emacs is not Microsoft Word " Xah
2008-11-10 10:11                       ` emacs is not Microsoft Word David Kastrup
2008-11-08 18:57                     ` emacs-w3m question Rupert Swarbrick
2008-11-08 21:33                       ` Xah
2008-11-09  6:26               ` Wei Weng
2008-11-09  8:55                 ` Xah
2008-11-10 21:25                   ` Xavier Maillard
     [not found]                   ` <mailman.21.1226352538.26697.help-gnu-emacs@gnu.org>
2008-11-10 22:38                     ` Xah
2008-11-11 21:46                       ` Emacs command frequencies: [was: emacs-w3m question] Alan Mackenzie
2008-11-12  2:28                       ` emacs-w3m question Sean Sieger
     [not found]                       ` <mailman.106.1226439293.26697.help-gnu-emacs@gnu.org>
2008-11-12  4:19                         ` Emacs command frequencies: [was: emacs-w3m question] Xah
2008-11-12 11:28                           ` Emacs command frequencies: Nikolaj Schumacher
2008-11-12 11:45                             ` Paul R
     [not found]                           ` <mailman.129.1226489296.26697.help-gnu-emacs@gnu.org>
2008-11-12 12:52                             ` Sébastien Vauban
2008-11-12 15:59                               ` Ted Zlatanov
2008-11-13 14:33                               ` Xah
2008-11-13  4:07                             ` Xah
2008-11-12 16:50                           ` Emacs command frequencies: [was: emacs-w3m question] rgb
2008-11-13 12:47                             ` Xah
2008-11-14 14:28                               ` rgb
2008-11-01 13:03         ` emacs-w3m question Andreas Politz
2008-11-03 11:25           ` Xavier Maillard
     [not found]           ` <mailman.2763.1225711681.25473.help-gnu-emacs@gnu.org>
2008-11-06 16:51             ` Andreas Politz
2008-10-27 21:48 ` Andreas Politz
2008-10-28 10:50   ` Francis Moreau
2008-10-28 14:51   ` OtherMichael
  -- strict thread matches above, loose matches on Subject: below --
2022-11-01 20:25 Jon Fineman
2022-11-02 12:32 ` Michael Heerdegen
2022-11-02 17:44   ` Jon Fineman
2022-11-03 11:18     ` Michael Heerdegen
2022-11-08  3:58       ` Bob Newell
2022-11-02 13:20 ` Emanuel Berg
2022-11-02 17:32   ` Jon Fineman
2022-11-02 18:22     ` Emanuel Berg
2022-11-03 17:56     ` Bob Newell
2022-11-04  2:02       ` Jon Fineman
2022-11-06 22:49       ` Bob Newell
2022-11-07  6:08         ` Yuri Khan
2022-11-07  6:38           ` Bob Newell
2022-11-07  6:45           ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-07  6:59             ` Yuri Khan
2022-11-07 12:34             ` Emanuel Berg
2022-11-07 12:40           ` Emanuel Berg
2022-11-02 22:14 ` Bob Newell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e01d8a50811071714p169688bds86bd0bdb3266dc4e@mail.gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=acm@muc.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=paul.r.ml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).