Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:02:34+00:00 2026-05-23T16:02:34+00:00

I am not sure whether this is just a simple mistake of my code.

  • 0

I am not sure whether this is just a simple mistake of my code. But I just cannot figure out what’s the problem is, so please point it out.

aaaaa

(progn 
  (setq ol-list nil) 
  (dolist (pos '(1 2 3 4))
    (let ( (ol (make-overlay pos (1+ pos) (current-buffer))) )
      (overlay-put ol 'display "X")
      (print ol)
      (setq ol-list
            (nconc ol-list (list ol)))
      );; let
    )  ;; dolist
  ) 


(progn 
  (dolist (ol ol-list)
    (delete-overlay ol))
  (setq ol-list nil) ) 

Put the above code snippet at the beginning your “lisp-mode” buffer, and eval (C-x C-e) each progn section.

On my emacs, the first code section will make the “aaaaa” to “Xa”. But I think the result should be “XXXXa”. So where is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:02:34+00:00Added an answer on May 23, 2026 at 4:02 pm

    See the Emacs Lisp manual, section 38.15.1:

    For replacing display specifications, “the text that has the property” means all the consecutive characters that have the same Lisp object as their display property; these characters are replaced as a single unit.

    The manual goes on to explain how to do what you want. You need to allocate a different string for each overlay. Something like this:

    (overlay-put ol 'display (concat "X"))
    

    I also have a couple of suggestions to make your code more Lisp-like:

    • There’s no need to put closing parentheses on their own line (see this answer). Emacs shows you matching parentheses, and does automatic indentation, so just leave the closing parentheses where they fall.

    • Your loops will look nicer if you use the loop facility and mapcar respectively.

    (require 'cl)
    
    (setq ol-list
      (loop for pos from 1 upto 4
            collect (let ((ol (make-overlay pos (1+ pos))))
                      (overlay-put ol 'display (concat "X"))
                      ol)))
    
    (mapcar #'delete-overlay ol-list)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this is just a simple Javascript scoping issue (go figure), but I've
I'm not sure whether this question belongs on StackOverflow or SuperUser, but here goes
we're having this toshiba barcode printer. I'm not sure whether this problem is hardware
I am not sure whether this only happens to me. Basically if I have
I'm not sure whether or not this is the appropriate way of doing this,
I'm not sure whether I'm asking the question correctly, but I've been told SQL
I am not sure whether it has been disscussed before or not but I
EDIT: Fixed most of the problem (but not too sure why). Check the bottom
I'm not sure whether to post it here or at ServerFault. Anyway, I'm trying
I am not entirely sure whether MONO_THEME is supposed to do anything for WinForms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.