"push" creating circular objects
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
"push" creating circular objects         


Author: Charles Sebold
Date: Aug 20, 2008 06:25

This is killing me.

I'm running GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600), the one that's
distributed from the FSF website. I've also verified this with 21.3,
21.4, and 22.1 from Debian sarge, etch, and lenny. I've done this with
"-q -no-site-file".

Here's the code in question:

(defun Textile-list-context (textile-list-tag)
"Return list of HTML tags corresponding to list context (ol, ul)."
(let ((my-list nil))
(dolist (this-tag (delete "" (split-string textile-list-tag "")))
(cond
((string= this-tag "#")
(push "ol" my-list))
((string= this-tag "*")
(push "ul" my-list))))
my-list))
Show full article (1.44Kb)
13 Comments
Re: "push" creating circular objects         


Author: Charles Sebold
Date: Aug 20, 2008 09:27

On 20 Aug 2008, Charles Sebold wrote:
> Here's the code in question:
>
> (defun Textile-list-context (textile-list-tag)
> "Return list of HTML tags corresponding to list context (ol, ul)."
> (let ((my-list nil))
> (dolist (this-tag (delete "" (split-string textile-list-tag "")))
> (cond
> ((string= this-tag "#")
> (push "ol" my-list))
> ((string= this-tag "*")
> (push "ul" my-list))))
> my-list))

I just changed it from push to append, with no change in behavior:
Show full article (0.99Kb)
no comments
Re: "push" creating circular objects         


Author: Charles Sebold
Date: Aug 20, 2008 12:07

On 20 Aug 2008, Charles Sebold wrote:
> I just changed it from push to append, with no change in behavior:

Now I tried something even more radical, a completely different approach
to the problem, just to see what happens.

(defun Textile-list-context (textile-list-tag)
"Return list of HTML tags corresponding to list context (ol, ul)."
(let ((my-list (delete " " (delete "" (split-string textile-list-tag "")))))
(mapcar (lambda (x)
(cond
((string= x "#")
"ol")
((string= x "*")
"ul")
(t
nil))) my-list)))

_It still returns a circular list._

And it still does the right thing, when I call it from a scratch buffer.
Show full article (0.89Kb)
no comments
Re: "push" creating circular objects         


Author: weber
Date: Aug 20, 2008 14:47

On Aug 20, 4:07 pm, Charles Sebold gmail.com> wrote:
> On 20 Aug 2008, Charles Sebold wrote:
>
>> I just changed it from push to append, with no change in behavior:
>
> Now I tried something even more radical, a completely different approach
> to the problem, just to see what happens.
>
> (defun Textile-list-context (textile-list-tag)
>   "Return list of HTML tags corresponding to list context (ol, ul)."
>   (let ((my-list (delete " " (delete "" (split-string textile-list-tag "")))))
>     (mapcar (lambda (x)
>               (cond
>                ((string= x "#")
>                 "ol")
>                ((string= x "*")
>                 "ul")
>                (t
>                 nil))) my-list)))
> ...
Show full article (1.46Kb)
no comments
Re: "push" creating circular objects         


Author: weber
Date: Aug 20, 2008 14:50

On Aug 20, 4:07 pm, Charles Sebold gmail.com> wrote:
> On 20 Aug 2008, Charles Sebold wrote:
>
>> I just changed it from push to append, with no change in behavior:
>
> Now I tried something even more radical, a completely different approach
> to the problem, just to see what happens.
>
> (defun Textile-list-context (textile-list-tag)
>   "Return list of HTML tags corresponding to list context (ol, ul)."
>   (let ((my-list (delete " " (delete "" (split-string textile-list-tag "")))))
>     (mapcar (lambda (x)
>               (cond
>                ((string= x "#")
>                 "ol")
>                ((string= x "*")
>                 "ul")
>                (t
>                 nil))) my-list)))
> ...
Show full article (1.41Kb)
no comments
Re: "push" creating circular objects         


Author: Charles Sebold
Date: Aug 21, 2008 07:12

On Aug 20, 4:50 pm, weber gmail.com> wrote:
> Minor variation:
>
> (defun test2 (str)
> (let (my-list)
> (with-temp-buffer
> (insert str)
> (goto-char (point-min))
> (while (not (eobp))
> (cond
> ((= (char-after) ?#)
> (push "ol" my-list))
> ((= (char-after) ?*)
> (push "ul" my-list)))
> (forward-char 1)))
> my-list))
>
> no need to bind my-list to nil too :)

Useful tip, thanks.
Show full article (1.10Kb)
no comments
Re: "push" creating circular objects         


Author: xraysmalevich
Date: Aug 21, 2008 07:25

On Aug 21, 10:12 am, Charles Sebold gmail.com> wrote:
> On Aug 20, 4:50 pm, weber gmail.com> wrote:
>
>
>
>> Minor variation:
>
>> (defun test2 (str)
>> (let (my-list)
>> (with-temp-buffer
>> (insert str)
>> (goto-char (point-min))
>> (while (not (eobp))
>> (cond
>> ((= (char-after) ?#)
>> (push "ol" my-list))
>> ((= (char-after) ?*)
>> (push "ul" my-list)))
>> (forward-char 1)))
>> my-list)) ...
Show full article (1.35Kb)
no comments
Re: "push" creating circular objects         


Author: Charles Sebold
Date: Aug 21, 2008 08:23

On 21 Aug 2008, xraysmalevich@gmail.com wrote:
> To check if you've rebound a function, try running emacs without the
> init file (emacs -q) and see if that changes this behavior.

Yeah, I mentioned at the top that I tried that (and went to clean
systems elsewhere without my .emacs and so forth and tried it, too).
No, whatever is happening, it's happening in the midst of the program
that's calling this function, I guess. I don't consciously rebind
anything elsewhere in the file. I've narrowed it down to one line, but
it's going to take some serious debugging to figure out what that has to
do with anything. I will post when I've figured it out, though (or when
I've given up, at which point I'll post the test code that produces the
problem and yell for help again).
--
Charles Sebold 21st of August, 2008
no comments
Re: "push" creating circular objects         


Author: John Paul Wallington
Date: Aug 21, 2008 09:14

Charles Sebold gmail.com> writes:
> In the scratch buffer, it works. In my program, it creates a circular
> list, represented as (#1="ul" #1#) as I edebug this.

Hey Charlie, it's great to see you posting on the Emacs newsgroups!

I'm not certain what's going on. Are you sure that representation means
circular structure? Or is it merely labelling the object "ul" for
future reference then referring to it? (See (elisp)Circular Objects.)

Also, how about consing up the strings with (string ?u ?l) or somesuch
to avoid 'em being treated as the same?
no comments
Re: "push" creating circular objects         


Author: Charles Sebold
Date: Aug 21, 2008 09:49

On 21 Aug 2008, John Paul Wallington wrote:
> I'm not certain what's going on. Are you sure that representation
> means circular structure? Or is it merely labelling the object "ul"
> for future reference then referring to it? (See (elisp)Circular
> Objects.)

I am likely confused. Is this not the same thing?

Oh. I guess it isn't. This is one of the insights I needed, I think.
> Also, how about consing up the strings with (string ?u ?l) or somesuch
> to avoid 'em being treated as the same?

I'll give that a try... yeah, that fixed it. I'm surprised I have to do
this, though. Why are they being treated as the same?

Knowing this, I replaced (string ?u ?l) with (copy-sequence "ul") and so
forth, and got the same result.

Thanks very much for this. But I'm surprised I have to do it.
--
Charles Sebold 21st of August, 2008
no comments
1 2