all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>"
@ 2014-10-15 16:00 Chris Seberino
  2014-10-15 16:55 ` Matthias Pfeifer
  2014-10-15 17:47 ` Barry Margolin
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Seberino @ 2014-10-15 16:00 UTC (permalink / raw)
  To: help-gnu-emacs


I tried to write a function that goes to next buffer **in alphabetical order**.
(I set f8 to call it.)

It makes a sorted version of buffer list and goes to next buffer in the list...


(global-set-key [f8]           (lambda () (interactive)
                                (let ((sorted-list
                                       (sort (buffer-list) 'string<)))
                                     (switch-to-buffer
                                      (nth 2
                                           (member
                                            (current-buffer) sorted-list))))))

Any help greatly appreciated.

cs


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>"
  2014-10-15 16:00 Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>" Chris Seberino
@ 2014-10-15 16:55 ` Matthias Pfeifer
  2014-10-15 17:47 ` Barry Margolin
  1 sibling, 0 replies; 3+ messages in thread
From: Matthias Pfeifer @ 2014-10-15 16:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Chris,

(buffer-list) does not evaluate into a list of strings like you expect it
evaluates into a list of buffer objects and these can not be compred with
your comparison function string<. I expect that if you debug your code you
find that the string< function emits the error message.

matthias

On Wed, 15 Oct 2014 09:00:07 -0700 (PDT)
Chris Seberino <cseberino@gmail.com> wrote:

> 
> I tried to write a function that goes to next buffer **in alphabetical order**.
> (I set f8 to call it.)
> 
> It makes a sorted version of buffer list and goes to next buffer in the list...
> 
> 
> (global-set-key [f8]           (lambda () (interactive)
>                                 (let ((sorted-list
>                                        (sort (buffer-list) 'string<)))
>                                      (switch-to-buffer
>                                       (nth 2
>                                            (member
>                                             (current-buffer) sorted-list))))))
> 
> Any help greatly appreciated.
> 
> cs


-- 
Matthias Pfeifer <mpfeifer77@gmail.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>"
  2014-10-15 16:00 Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>" Chris Seberino
  2014-10-15 16:55 ` Matthias Pfeifer
@ 2014-10-15 17:47 ` Barry Margolin
  1 sibling, 0 replies; 3+ messages in thread
From: Barry Margolin @ 2014-10-15 17:47 UTC (permalink / raw)
  To: help-gnu-emacs

In article <da029a7b-908d-4e04-9298-10a630bca567@googlegroups.com>,
 Chris Seberino <cseberino@gmail.com> wrote:

> I tried to write a function that goes to next buffer **in alphabetical 
> order**.
> (I set f8 to call it.)
> 
> It makes a sorted version of buffer list and goes to next buffer in the 
> list...
> 
> 
> (global-set-key [f8]           (lambda () (interactive)
>                                 (let ((sorted-list
>                                        (sort (buffer-list) 'string<)))
>                                      (switch-to-buffer
>                                       (nth 2
>                                            (member
>                                             (current-buffer) 
>                                 sorted-list))))))


(buffer-list) returns a list of buffers, not a list of strings. You 
can't compare them with string<. Try:

(sort (buffer-list)
      (lambda (buf1 buf2)
        (string< (buffer-name buf1) (buffer-name buf2))))

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-15 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 16:00 Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>" Chris Seberino
2014-10-15 16:55 ` Matthias Pfeifer
2014-10-15 17:47 ` Barry Margolin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.