noctuid / emacs-sentence-navigation

(Broken) Better Sentence Movement Commands and Evil Text Objects
GNU General Public License v3.0
29 stars 3 forks source link

** Evil Note that =)= and =(= are bound in motion state by default. Keys bound in motion state are inherited by the normal, visual, and operator states if they are not explicitly bound in those states.

+begin_src emacs-lisp

(define-key evil-motion-state-map ")" 'sentence-nav-evil-forward) (define-key evil-motion-state-map "(" 'sentence-nav-evil-backward) (define-key evil-motion-state-map "g)" 'sentence-nav-evil-forward-end) (define-key evil-motion-state-map "g(" 'sentence-nav-evil-backward-end) (define-key evil-outer-text-objects-map "s" 'sentence-nav-evil-a-sentence) (define-key evil-inner-text-objects-map "s" 'sentence-nav-evil-inner-sentence)

+end_src

** No Evil

+begin_src emacs-lisp

(global-set-key (kbd "M-e") 'sentence-nav-forward) (global-set-key (kbd "M-a") 'sentence-nav-backward)

+end_src

Both ~sentence-nav-forward-end~ and ~sentence-nav-backward-end~ can also be bound.

** Abbreviations The list of abbreviations to ignore can be customized. The defaults are mostly the same as vim-textobj-sentence's.

+begin_src emacs-lisp

(setq sentence-nav-abbreviation-list '("[ABCDIMPSUabcdegimpsv]" "l[ab]" "[eRr]d" "Ph" "[Ccp]l" "[Ll]n" "[c]o" "[Oe]p" "[DJMSh]r" "[MVv]s" "[CFMPScfpw]t" "alt" "[Ee]tc" "div" "es[pt]" "[Ll]td" "min" "[MD]rs" "[Aa]pt" "[Aa]ve?" "[Ss]tr?" "e\.g" "[Aa]ssn" "[Bb]lvd" "[Dd]ept" "incl" "Inst" "Prof" "Univ"))

+end_src

** Jump Locations By default, any delimiters that can surround a sentence such as quotation marks will be considered as part of the start or end of a sentence. This means that the jump commands will jump to quotation marks. If you would prefer to have the commands always jump to the capital letter at the start of the sentence or the period at the end, you can set =sentence-nav-jump-to-syntax= to =nil=.

For evil users, =sentence-nav-syntax-text-objects= can be set to a non-nil value to change the distinction between the inner and outer text objects. When this variable is non-nil, the outer text object will include any delimiters such as quotation marks while the inner text object will not.

** Accurate Jumps for Hard-Wrapped Sentences By default, this package assumes that a capital letter at the beginning of the line starts a sentence. While this works fine for soft-wrapped sentences, it can result in incorrect jumps when using hard-wrapped sentences (e.g. when a line begins with a name that is in the middle of a sentence). To fix this, users must set =sentence-nav-hard-wrapping= to a non-nil value and ensure that =sentence-nav-non-sentence-line-alist= is properly set for the =major-mode= being used. This is necessary to ensure that sentences that start the line after some markup (e.g. a markdown or org heading) are handled correctly.

;; alternatively after starting emacs in the relevant buffer (modify-syntax-entry ?# "<")

+end_src

Another example for text mode:

+begin_src emacs-lisp

(modify-syntax-entry ?# "<" text-mode-syntax-table)

+end_src