help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: how to implement function copy-subword-to-irc-buffer


From: Kevin Rodgers
Subject: Re: how to implement function copy-subword-to-irc-buffer
Date: Tue, 01 Dec 2009 23:34:21 -0700
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

B. T. Raven wrote:
I think I need (thing-at-point 'word), (buffer-list), set point and
mark, copy-region-as-kill-no-mark, and other usual suspects to implement
this but really want to automatically copy the substring of the word
before point or the whole word if point is in whitespace after the word.
This (sub)string should go to the point in the irc buffer (one whose
buffer-name starts with #) and then make that irc buffer current.

Looking at rcirc.el, it does not look like that is a reliable method to select
"the" IRC buffer.  It actually supports multiple IRC buffers, maintained in
rcirc-buffer-alist (which is local to the server buffer, of which there may
also be more than 1).

Glossing over that for the moment, how about:

(let* ((subword (if (looking-at "\\>")
                    (thing-at-point 'word)
                  (buffer-substring (or (car (bounds-of-thing-at-point 'word))
                                        (point))
                                    (point))))
       (buffer-list (buffer-list))
       (irc-buffer (catch 'irc-buffer
                     (while buffer-list
                       (when (and (string-match "^#"
                                                (buffer-name (car buffer-list)))
                                  (buffer-local-value 'rcirc-server-buffer
                                                      (car buffer-list)))
                         (throw 'irc-buffer (car buffer-list)))
                       (setq buffer-list (cdr buffer-list))))))
  (when irc-buffer
    (funcall rcirc-switch-to-buffer-function irc-buffer)
    (insert subword)))

Is this doable? I want to assign this function to some keychord but am
not sure what would be suitable (in keeping with traditional key
assignment philosophy). I have standard binding for almost every thing
but single character cursor movement. Is there a way of getting a list
of all key combos (and/or ranges of key combos) that are not currently
bound?

From the Keymaps node of the Emacs manual:

,----
|    As a user, you can redefine any key; but it is usually best to stick
| to key sequences that consist of `C-c' followed by a letter (upper or
| lower case).  These keys are "reserved for users," so they won't
| conflict with any properly designed Emacs extension.  The function keys
| <F5> through <F9> are also reserved for users.  If you redefine some
| other key, your definition may be overridden by certain extensions or
| major modes which redefine the same key.
|
`----

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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