erc-discuss
[Top][All Lists]
Advanced

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

[Erc-discuss] C-c C-SPC keybinding conflict workaround (was: FOR-RELEASE


From: Michael Olson
Subject: [Erc-discuss] C-c C-SPC keybinding conflict workaround (was: FOR-RELEASE items)
Date: Thu, 29 Mar 2007 23:30:59 -0400
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.94 (gnu/linux)

Ryan Yeske <address@hidden> writes:

> Michael Olson <address@hidden> writes:
>
>>   *** Change keybinding definitions for `erc-track-switch-buffer'.
>>   `C-c C-SPC' / `C-c C-@' is set as a global keybinding and is known
>>   to conflict with rcirc, for example.  Would setting
>>   `erc-track-mode-map' work?  Otherwise we could encourage people to
>>   use something like `C-c e SPC' or `C-c c'.
>>
>> I really don't want to change that keybinding -- it's comfortable, and
>> rather famous in terms of features that attract people to Emacs-based
>> IRC clients.  Better perhaps would be to have a compatibility function
>> that would get activated whenever either erc.el or rcirc.el was
>> loaded, and choose between them depending on which has an open
>> connection.  If both have open connections, prompt for which client to
>> connect to.  This function would be bound to C-c C-SPC in Emacs 22,
>> but not in the standalone ERC releases.
>
> I use rcirc-track-minor-mode for the C-c C-SPC binding in rcirc.  I
> would like to make it possible to run both clients at the same time,
> and have C-c C-SPC dtrt.
>
> So, I'm open to making whatever changes might be necessary on my end
> to make this co-operation possible.

I've checked in code which implements a similar solution, except that
erc-track-minor-mode only handles the keybindings and nothing else.
This fits with ERC's module system reasonably well.

The default behavior should be preserved, with the following caveat:
if you've set C-c C-SPC or C-c C-@ manually, ERC will ask you whether
it's OK to override that keybinding.  To make this message go away,
see the `erc-track-enable-keybindings' option.

Here's the code for prompting the user, in case it comes in handy for
rcirc.

(defcustom erc-track-enable-keybindings 'ask
  "Whether to enable the ERC track keybindings, namely:
`C-c C-SPC' and `C-c C-@', which both do the same thing.

The default is to check to see whether these keys are used
already: if not, then enable the ERC track minor mode, which
provides these keys.  Otherwise, do not touch the keys.

This can alternatively be set to either t or nil, which indicate
respectively always to enable ERC track minor mode or never to
enable ERC track minor mode.

The reason for using this default value is to both (1) adhere to
the Emacs development guidelines which say not to touch keys of
the form C-c C-<something> and also (2) to meet the expectations
of long-time ERC users, many of whom rely on these keybindings."
  :group 'erc-track
  :type '(choice (const :tag "Ask, if used already" ask)
                 (const :tag "Enable" t)
                 (const :tag "Disable" nil)))

(defun erc-track-minor-mode-maybe ()
  "Enable `erc-track-minor-mode', depending on `erc-track-enable-keybindings'."
  (unless (or erc-track-minor-mode
              ;; don't start the minor mode until we have an ERC
              ;; process running, because we don't want to prompt the
              ;; user while starting Emacs
              (null (erc-buffer-list)))
    (cond ((eq erc-track-enable-keybindings 'ask)
           (let ((key (or (and (key-binding (kbd "C-c C-SPC")) "C-SPC")
                          (and (key-binding (kbd "C-c C-@")) "C-@"))))
             (if key
                 (if (y-or-n-p
                      (concat "The C-c " key " binding is in use;"
                              " override it for tracking? "))
                     (progn
                       (message (concat "Will change it; set"
                                        " `erc-track-enable-keybindings'"
                                        " to disable this message"))
                       (sleep-for 3)
                       (erc-track-minor-mode 1))
                   (message (concat "Not changing it; set"
                                    " `erc-track-enable-keybindings'"
                                    " to disable this message"))
                   (sleep-for 3))
               (erc-track-minor-mode 1))))
          ((eq erc-track-enable-keybindings t)
           (erc-track-minor-mode 1))
          (t nil))))

-- 
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: Lisp, text markup, protocols -- Jabber: mwolson_at_hcoop.net
  /` |\ | | | Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC
 |_] | \| |_| Reclaim your digital rights by eliminating DRM.
      See http://www.defectivebydesign.org/what_is_drm for details.

Attachment: pgptRtUwqJwXb.pgp
Description: PGP signature


reply via email to

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