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

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

Re: Why function gives this error?.. "Wrong type argument: stringp, #<bu


From: Barry Margolin
Subject: Re: Why function gives this error?.. "Wrong type argument: stringp, #<buffer *Messages*>"
Date: Wed, 15 Oct 2014 13:47:54 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

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 ***


reply via email to

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