From: Andreas Gerler Date: Mon, 27 Mar 2017 20:51:25 +0000 (+0200) Subject: added Xah Lee move cursor to bracket. X-Git-Url: http://git.bundesbrandschatzamt.de/?a=commitdiff_plain;h=d5c96bc0f351b71437c5290a42c23687e4c181a2;p=emacsconfig.git added Xah Lee move cursor to bracket. Signed-off-by: Andreas Gerler --- diff --git a/bba.org b/bba.org index b6309e7d..af185942 100644 --- a/bba.org +++ b/bba.org @@ -2823,6 +2823,54 @@ Thanks to [[http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line (define-key global-map (kbd "M-w") 'xah-copy-line-or-region) #+END_SRC +* [[http://ergoemacs.org/emacs/emacs_navigating_keys_for_brackets.html][Xah Lee Move cursor to Bracket]] +[2017-03-27 Mon 22:41] + +#+BEGIN_SRC emacs-lisp :tangle yes + (defvar xah-brackets nil "string of left/right brackets pairs.") + (setq xah-brackets "()[]{}<>()[]{}⦅⦆〚〛⦃⦄“”‘’‹›«»「」〈〉《》【】〔〕⦗⦘『』〖〗〘〙「」⟦⟧⟨⟩⟪⟫⟮⟯⟬⟭⌈⌉⌊⌋⦇⦈⦉⦊❛❜❝❞❨❩❪❫❴❵❬❭❮❯❰❱❲❳〈〉⦑⦒⧼⧽﹙﹚﹛﹜﹝﹞⁽⁾₍₎⦋⦌⦍⦎⦏⦐⁅⁆⸢⸣⸤⸥⟅⟆⦓⦔⦕⦖⸦⸧⸨⸩⦅⦆⧘⧙⧚⧛⸜⸝⸌⸍⸂⸃⸄⸅⸉⸊᚛᚜༺༻༼༽⏜⏝⎴⎵⏞⏟⏠⏡﹁﹂﹃﹄︹︺︻︼︗︘︿﹀︽︾﹇﹈︷︸") + + (defvar xah-left-brackets '("(" "{" "[" "<" "〔" "【" "〖" "〈" "《" "「" "『" "“" "‘" "‹" "«" ) + "List of left bracket chars.") + (progn + ;; make xah-left-brackets based on xah-brackets + (setq xah-left-brackets '()) + (dotimes (-x (- (length xah-brackets) 1)) + (when (= (% -x 2) 0) + (push (char-to-string (elt xah-brackets -x)) + xah-left-brackets))) + (setq xah-left-brackets (reverse xah-left-brackets))) + + (defvar xah-right-brackets '(")" "]" "}" ">" "〕" "】" "〗" "〉" "》" "」" "』" "”" "’" "›" "»") + "list of right bracket chars.") + (progn + (setq xah-right-brackets '()) + (dotimes (-x (- (length xah-brackets) 1)) + (when (= (% -x 2) 1) + (push (char-to-string (elt xah-brackets -x)) + xah-right-brackets))) + (setq xah-right-brackets (reverse xah-right-brackets))) + + (defun xah-backward-left-bracket () + "Move cursor to the previous occurrence of left bracket. + The list of brackets to jump to is defined by `xah-left-brackets'. + URL `http://ergoemacs.org/emacs/emacs_navigating_keys_for_brackets.html' + Version 2015-10-01" + (interactive) + (search-backward-regexp (regexp-opt xah-left-brackets) nil t)) + + (defun xah-forward-right-bracket () + "Move cursor to the next occurrence of right bracket. + The list of brackets to jump to is defined by `xah-right-brackets'. + URL `http://ergoemacs.org/emacs/emacs_navigating_keys_for_brackets.html' + Version 2015-10-01" + (interactive) + (re-search-forward (regexp-opt xah-right-brackets) nil t)) + + (define-key global-map (kbd "s-,") 'xah-backward-left-bracket) + (define-key global-map (kbd "s-.") 'xah-forward-right-bracket) +#+END_SRC + * copy buffer file name to kill ring Sometimes you need the filename of your current buffer on the command