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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:22:43+00:00 2026-05-19T12:22:43+00:00

I would like to be able to navigate by sentence in Emacs (M-a, M-e).

  • 0

I would like to be able to navigate by sentence in Emacs (M-a, M-e). Here’s the problem: by default, Emacs expects that each sentence is separated by two spaces, and I’m used to just putting a single space. Of course, that setting can be turned off, to allow for sentences separated by only a single space, like so:

(setq sentence-end-double-space nil)   

But then Emacs thinks that a sentence has ended after abbreviations with a full stop (“.”), e.g. after something like “…a weird command, e.g. foo…”.

So rather than using the above code, is there a way to define the sentence-end variable so that it counts [.!?] as marking the end of the sentence, iff what follows is one or more spaces followed by a capital letter [A-Z]?

And…to also allow [.!?] to mark the end of a sentence, if followed by zero or more spaces followed by a “\”? [The reason for this latter condition is for writing LaTeX code: where a sentence is followed by a LaTeX command like \footnote{}, e.g. “…and so we can see that the point is proved.\footnote{In some alternate world, at least.}”]

I tried playing around with the definition of sentence-end, and came up with:

(setq sentence-end "[.!?][]'\")}]*\\(\\$\\|[ ]+[A-Z]\\|[ ]+[A-Z]\\| \\)[
 ;]*")

But this doesn’t seem to work at all.

Any suggestions?

  • 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-19T12:22:44+00:00Added an answer on May 19, 2026 at 12:22 pm

    I don’t think sentence-end will do what you need it to do. You really need look-ahead regexps for this, and Emacs doesn’t support them.

    You can roll your own function to do what you need though. I don’t understand all of your requirements, but the following is a start:

    (defun my-next-sentence ()
    "Move point forward to the next sentence.
    Start by moving to the next period, question mark or exclamation.
    If this punctuation is followed by one or more whitespace
    characters followed by a capital letter, or a '\', stop there. If
    not, assume we're at an abbreviation of some sort and move to the
    next potential sentence end"
      (interactive)
      (re-search-forward "[.?!]")
      (if (looking-at "[    \n]+[A-Z]\\|\\\\")
          nil
        (my-next-sentence)))
    
    (defun my-last-sentence ()
      (interactive)
      (re-search-backward "[.?!][   \n]+[A-Z]\\|\\.\\\\" nil t)
      (forward-char))
    

    Most of your tweaking will need to focus on the looking-at regexp, to make sure it hits all the potential end-of-sentence conditions you need. It would be relatively easy to modify it to move the cursor to particular locations based on what it finds: Leave it be if it’s a normal sentence, move past the next { if you’re at a latex command, or whatever suits you.

    Once you’ve got that working, can bind the functions to a M-a and M-e, probably using mode-hooks unless you want to use them for every mode.

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

Sidebar

Related Questions

I would like to be able to navigate a large Pdf file (275 pages)
Would like to be able to set colors of headings and such, different font
I would like to be able to loop through all of the defined parameters
We would like to be able to nightly make a copy/backup/snapshot of a production
I would like to be able to use the Tab key within a text
I would like to be able to display some dynamic text at the mouse
I would like to be able to obtain all the parameter values from the
I would like to be able to define and use a custom type in
I would like to be able to predict what will be in the resulting
I would like to be able to do such things as var m1 =

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.