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

  • Home
  • SEARCH
  • 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 225655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:26:05+00:00 2026-05-11T19:26:05+00:00

This is scenario that I ran into a few times: I copy some text

  • 0

This is scenario that I ran into a few times:

I copy some text from other program. Go to Emacs and did some editing before I paste/yank the text in. C-y to yank and voila … not the text I intended to paste in. Then I realize that while I am moving things around, I used commands like kill-line and backward-kill-word, and those killed lines and words now occupied the kill-ring. But typing M-y does not bring the original copied text back, so I need to go back to my original program to copy the text again. And even worst if the original program is closed, then I lost the copied text completely.

Kill-line, etc. are such basic commands (like hitting the delete key, almost), and while I don’t mind that the kill-ring gets a bit cluttered by using those command, I expect that my original text stays somewhere in the kill-ring so that I can eventually find it by typing M-y a few times. How can I make Emacs to automatically preserve the current clipboard content into the kill-ring before overriding the clipboard content?

  • 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-11T19:26:05+00:00Added an answer on May 11, 2026 at 7:26 pm

    This code should automatically put the selection (from outside Emacs) onto the kill-ring any time you do a kill in Emacs. It’s been tested on Linux, but shouldn’t be restricted to Linux.

    (defadvice kill-new (before kill-new-push-xselection-on-kill-ring activate)
      "Before putting new kill onto the kill-ring, add the clipboard/external selection to the kill ring"
      (let ((have-paste (and interprogram-paste-function
                             (funcall interprogram-paste-function))))
        (when have-paste (push have-paste kill-ring))))
    

    If you find yourself doing this a lot, it may be useful to take a look at the package browse-kill-ring, which gives you a nice view of the kill ring (as opposed to repeatedly typing M-y).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hoping someone has ran into this scenario and can lead me in the right
How is it possible that .NET is finding the wrong MyType in this scenario?
How would you test this scenario? I've just started looking into NHibernate and having
Ran into this issue yesterday on one of our sites. First of all the
I ran into a scenario where LINQ to SQL acts very strangely. I would
I ran into this problem at my old job, and now again at my
I have this scenario where I need data integrity in the physical database. For
we have this scenario: A server which contains needed data and client component which
I need to set up this scenario: A SQL Server 2005 database will create
This is a question for a WSS/SharePoint guru. Consider this scenario: I have an

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.