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 649535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:57:17+00:00 2026-05-13T21:57:17+00:00

I would like to temporarily override the kill-new function. I have a way I

  • 0

I would like to temporarily override the kill-new function. I have a way I want to reimplement kill-new that works in only in certain contexts, but I don’t want to reimplement a special version of kill-region on top of that. (kill-new is called from kill-region)

Since Emacs Lisp uses dynamic scoping, this should be possible, right? (On the other hand, it seems that this would be an unsafe thing to support, and it might make me a bit nervous knowing that it is possible…)

I have experimented with using let and fset, but so far have found no way to get it to work as expected. So, hopefully someone can fill in the blank in the following pseudocode:

(defun my-kill-new (string &optional replace yank-handler) 
   (message "in my-kill-new!"))

(defun foo ()
   (some-form-that-binds-a-function (kill-new my-kill-new)
   (kill-region (point) (mark))))

What should some-form-that-binds-a-function be? Or am I barking up the wrong tree?

  • 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-13T21:57:18+00:00Added an answer on May 13, 2026 at 9:57 pm

    Here is a solution:

    (defadvice kill-new (around my-kill-new (string &optional replace yank-handler)) 
       (message "my-kill-new!"))
    
    
    (defun foo ()
      (progn (ad-enable-advice 'kill-new 'around 'my-kill-new)
         (ad-activate 'kill-new)
         (kill-region (point) (mark))
         (ad-disable-advice 'kill-new 'around 'my-kill-new)
         (ad-activate 'kill-new)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a navigation controller-based app in which I would like to temporarily disable
At a certain point in my application, I would like to temporarily disable the
I have a Silverlight 3 Navigation Application and I would like to temporarily disable
I would like to store data temporarily on clientside. What is the best way
I have a MFC application written in VC6. I would like to temporarily allocate
I have two classes in my project that I would like to pass the
I want to override certain function calls to various APIs for the sake of
I have a Java Applet that is generating an image. Ultimately, I would like
I would like to temporarily impersonate a domain user account to read in a
I would like to change the logged in user to another user temporarily to

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.