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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:58:41+00:00 2026-06-18T00:58:41+00:00

I have many handy functions which operate on the current word or region, and

  • 0

I have many handy functions which operate on the current word or region, and due to laziness etc. I’ve build them out of a template…

For example

(defun lower-camelcase-at-point-or-region ()
  "lowerCamelCaseTheCurrent dashed or snake_case word or any words in text selection."
  (interactive)
  (let (pos1 pos2 meat)
    (if (and transient-mark-mode mark-active)
        (setq pos1 (region-beginning)
              pos2 (region-end))
      (setq pos1 (car (bounds-of-thing-at-point 'symbol))
            pos2 (cdr (bounds-of-thing-at-point 'symbol))))
    (setq meat (s-lower-camel-case (buffer-substring-no-properties pos1 pos2)))
    (delete-region pos1 pos2)
    (insert  meat)    
    )
  )

Effectively this is all boiler plate, except for this line…

(setq meat (s-lower-camel-case (buffer-substring-no-properties pos1 pos2)))

Where I call s-lower-camel-case on the buffer substring. I want to reuse the at point or region stuff, but without duplicating it everywhere, (because that’s stupid, and a headache to maintain.)

So what I really want to know is, can I curry functions in Emacs Lisp?

When I tried this…

(defun do-stuff-on-point-or-region ()
  "Do stuff."
  (interactive)
  (operate-on-point-or-region 's-lower-camel-case)
)

With operate-on-point-or-region defined as…:

(defun operate-on-point-or-region (fn)
  "Pick the substring at point, or region 
   and replace it with the output of fn"
  (let (pos1 pos2 meat)
    (if (and transient-mark-mode mark-active)
        (setq pos1 (region-beginning)
              pos2 (region-end))
      (setq pos1 (car (bounds-of-thing-at-point 'symbol))
            pos2 (cdr (bounds-of-thing-at-point 'symbol))))
    (setq meat (fn (buffer-substring-no-properties pos1 pos2)))
    (delete-region pos1 pos2)
    (insert  meat)    
    )
)

I get : Symbol's function definition is void: fn

Am I foolishly assuming currying is possible in Emacs Lisp!? Or am I just doing it wrong?

  • 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-06-18T00:58:42+00:00Added an answer on June 18, 2026 at 12:58 am

    First, emacs-lisp is, kinda, sorta, a 2-lisp, so the following is invalid:

    (defun foo (fn)
      (fn 3)) ;; DOES NOT WORK!
    

    Instead, you have to do the following:

    (defun foo (fn)
      (funcall fn 3))
    

    So if you replace (setq meat (fn with (setq meat (funcall fn the code ought to work.

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

Sidebar

Related Questions

I have many many files in a folder, and I want to process them
I have many directories with files in them. I want to create a comma
I have many flags that I want to store them in an integer, so
I have many text files containing bank transactions in the middle of them. Each
I have many MKMapViews, and each of them has an annotation. I am trying
I have a business model called Customer which has many required properties (via DataAnnotations)
This Javascript which uses functions from jQuery is quite handy but getting feedback on
I have an ASP.NET Menu which generates many anchor tags when rendered. My requirements
I have many different NSArray 's stored in .dat files, in the Documents folder
I have many PowerPoint presentations that I need to be able to add 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.