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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:27:12+00:00 2026-06-17T08:27:12+00:00

Consider the following line of Lisp code: (some-function 7 8 | 9) ;; some

  • 0

Consider the following line of Lisp code:

        (some-function 7 8 | 9) ;; some comment. note the extra indentation

The point is placed between ‘8’ and ‘9’. If I perform (move-beginning-of-line), the point will be placed at the absolute beginning of the line, rather than at ‘(‘.

Same for move-end-of-line: I’d find it more desirable for it to place the point at ‘)’ if I perform it once, and at the absolute end of the line if I perform it a second time. Some IDEs behave like that.

I tried to implement this but got stuck, my solution behaves particularly bad near the end of a buffer, and on the minibuffer as well. Is there a library that provides this functionality?

  • 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-17T08:27:13+00:00Added an answer on June 17, 2026 at 8:27 am

    I don’t know of any library, but it can be done in a few lines of Elisp.

    For the beginning of line part, the bundled functions beginning-of-line-text and back-to-indentation (M-m) move to the beginning of the “interesting” part of the line. back-to-indentation ignores only whitespace whereas beginning-of-line-text skips over the fill prefix (in a programming language, this is typically the comment marker, if in a comment). See Smart home in Emacs for how to flip between the beginning of the actual and logical line.

    For the end of line part, the following function implements what you’re describing. The function end-of-line-code moves to the end of the line, except for trailing whitespace and an optional trailing comment. The function end-of-line-or-code does this, except that if the point was already at the target position, or if the line only contains whitespace and a comment, the point moves to the end of the actual line.

    (defun end-of-line-code ()
      (interactive "^")
      (save-match-data
        (let* ((bolpos (progn (beginning-of-line) (point)))
               (eolpos (progn (end-of-line) (point))))
          (if (comment-search-backward bolpos t)
              (search-backward-regexp comment-start-skip bolpos 'noerror))
          (skip-syntax-backward " " bolpos))))
    
    (defun end-of-line-or-code ()
      (interactive "^")
      (let ((here (point)))
        (end-of-line-code)
        (if (or (= here (point))
            (bolp))
            (end-of-line))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following three lines of Mathematica code and note that input line 1
Consider the following line: install --with-some-params some_pkg_name.10000 install --with-some-params other_pkg_name.10000 install --with-some-params yet_other_pkg_name.10000 I'm
Consider the following arbitrary line of code: $object = new My_Object(); In Netbeans you
Consider the following problem: A multi-line string $junk contains some lines which are encoded
Consider the following code: data = textscan(fid,'%s%d%d%d%d%f%d%f%f%f%d','Delimiter',',','HeaderLines',28) I want to break the line as
consider the following code: if (matcher1.find()) { String str = line.substring(matcher1.start()+7,matcher1.end()-1); /*+7 and -1
Consider the following line of code: things.Add(new Thing { ID = null, Name =
Consider the following line of code: private void DoThis() { int i = 5;
Consider the following code: function dbTask(q) { mysql = new MySQL(); mysql.host = sqlHost;
Consider following XML document fragment: <Book> <Title>Example</Title> <Content> Some line </Content> <TOC> Again some

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.