safe-load does not break emacs initialization, should a file be
unreadable while emacs boots up.
#+BEGIN_SRC emacs-lisp tangle:yes
- (defvar safe-load-error-list ""
- "*List of files that reported errors when loaded via safe-load")
-
- (defun safe-load (file &optional noerror nomessage nosuffix)
- "Load a file. If error on load, report back, wait for
- a key stroke then continue on"
- (interactive "f")
- (condition-case nil (load file noerror nomessage nosuffix)
- (error
- (progn
- (setq safe-load-error-list (concat safe-load-error-list " " file))
- (message "****** [Return to continue] Error loading %s" safe-load-error-list )
- (sleep-for 1)
- nil))))
-
- (defun safe-load-check ()
- "Check for any previous safe-load loading errors. (safe-load.el)"
- (interactive)
- (if (string-equal safe-load-error-list "") ()
- (message (concat "****** error loading: " safe-load-error-list))))
-#+END_SRC
-
-match-paren will either jump to the "other" paren or simply insert %
-#+BEGIN_SRC emacs-lisp tangle:yes
-(defun match-paren (arg)
- "Go to the matching parenthesis if on parenthesis otherwise insert %."
- (interactive "p")
- (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
- ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
- (t (self-insert-command (or arg 1)))))
- #+END_SRC
+(defvar safe-load-error-list ""
+ "*List of files that reported errors when loaded via safe-load")
+
+(defun safe-load (file &optional noerror nomessage nosuffix)
+ "Load a file. If error on load, report back, wait for
+ a key stroke then continue on"
+ (interactive "f")
+ (condition-case nil (load file noerror nomessage nosuffix)
+ (error
+ (progn
+ (setq safe-load-error-list (concat safe-load-error-list " " file))
+ (message "****** [Return to continue] Error loading %s" safe-load-error-list )
+ (sleep-for 1)
+ nil))))
+
+(defun safe-load-check ()
+ "Check for any previous safe-load loading errors. (safe-load.el)"
+ (interactive)
+ (if (string-equal safe-load-error-list "") ()
+ (message (concat "****** error loading: " safe-load-error-list))))
+#+END_SRC
I have some stuff put away in my local dir. I don't want to load it all
at startup time, so it is using the autoload feature. For that to work
(safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
#+END_SRC
-
Always ensure to have a scratch buffer around.
#+BEGIN_SRC emacs-lisp tangle:yes
(save-excursion
(add-to-list 'auto-mode-alist (cons pattern mode))))
#+END_SRC
-
Helpers for the config
#+BEGIN_SRC emacs-lisp tangle:yes
(require 'use-package)
I always use dark backgrounds, so tell Emacs about it. No need to
guess around.
#+BEGIN_SRC emacs-lisp tangle:yes
-(setq-default frame-background-mode 'dark)
+(setq-default frame-background-mode jj-color-style)
#+END_SRC
And I always liked dark backgrounds with colors setup for them. So I
I only list modes here where I don't have any other special
configuration.
-- Some extras for ruby, used with ruby on rails for example
-#+BEGIN_SRC emacs-lisp tangle:yes
-(add-to-list 'auto-mode-alist '("\\.rxml$" . ruby-mode))
-(add-to-list 'auto-mode-alist '("\\.rjs$" . ruby-mode))
-(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
-(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
-(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
-#+END_SRC
-
- Markdown syntax
#+BEGIN_SRC emacs-lisp tangle:yes
-(add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
+(add-auto-mode 'markdown-mode "\\.mdwn$")
#+END_SRC
- diff
#+BEGIN_SRC emacs-lisp tangle:yes
-(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
-#+END_SRC
-
-- perl
-#+BEGIN_SRC emacs-lisp tangle:yes
-(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
-(add-to-list 'auto-mode-alist '("\\.pod$" . pod-mode))
-(add-to-list 'auto-mode-alist '("\\.tt$" . tt-mode))
-(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
-(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
-(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
-#+END_SRC
-
-- python
-#+BEGIN_SRC emacs-lisp tangle:yes
-(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
-(add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
-(add-to-list 'interpreter-mode-alist '("python" . python-mode))
+(add-auto-mode 'diff-mode "COMMIT_EDITMSG$")
#+END_SRC
** Region bindings mode
(add-hook 'write-file-hooks 'time-stamp)
#+END_SRC
-** cperl
+** perl / cperl
I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
up here to be used.
#+BEGIN_SRC emacs-lisp tangle:yes
(autoload 'cperl-mode "cperl-mode" )
(defalias 'perl-mode 'cperl-mode)
-(setq cperl-hairy t)
-(setq cperl-electric-keywords t)
-(setq cperl-electric-lbrace-space t)
-(setq cperl-electric-parens nil)
-(setq cperl-highlight-variables-indiscriminately t)
-(setq cperl-imenu-addback t)
-(setq cperl-invalid-face (quote underline))
-(setq cperl-lazy-help-time 5)
-(setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
-(setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
-(setq cperl-syntaxify-by-font-lock t)
-(setq cperl-use-syntax-table-text-property-for-tags t)
-#+END_SRC
-
-And have cperl mode give ElDoc a useful string
-#+BEGIN_SRC emacs-lisp tangle:yes
-(defun my-cperl-eldoc-documentation-function ()
- "Return meaningful doc string for `eldoc-mode'."
- (car
- (let ((cperl-message-on-help-error nil))
- (cperl-get-help))))
-(add-hook 'cperl-mode-hook
- (lambda ()
- (set (make-local-variable 'eldoc-documentation-function)
- 'my-cperl-eldoc-documentation-function)
- (eldoc-mode)))
+(add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
+(add-auto-mode 'pod-mode "\\.pod$")
+(add-auto-mode 'tt-mode "\\.tt$")
+(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
+(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
+(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
+
+(after 'cperl-mode
+ (setq cperl-hairy t)
+ (setq cperl-electric-keywords t)
+ (setq cperl-electric-lbrace-space t)
+ (setq cperl-electric-parens nil)
+ (setq cperl-highlight-variables-indiscriminately t)
+ (setq cperl-imenu-addback t)
+ (setq cperl-invalid-face (quote underline))
+ (setq cperl-lazy-help-time 5)
+ (setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
+ (setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
+ (setq cperl-syntaxify-by-font-lock t)
+ (setq cperl-use-syntax-table-text-property-for-tags t)
+
+ ;; And have cperl mode give ElDoc a useful string
+ (defun my-cperl-eldoc-documentation-function ()
+ "Return meaningful doc string for `eldoc-mode'."
+ (car
+ (let ((cperl-message-on-help-error nil))
+ (cperl-get-help))))
+
+ (add-hook 'cperl-mode-hook
+ (lambda ()
+ (set (make-local-variable 'eldoc-documentation-function)
+ 'my-cperl-eldoc-documentation-function)
+ (eldoc-mode))))
#+END_SRC
** python
#+BEGIN_SRC emacs-lisp tangle:yes
- (autoload 'python-mode "python-mode" "Python Mode." t)
- (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
- (add-to-list 'interpreter-mode-alist '("python" . python-mode))
- (setq interpreter-mode-alist
- (cons '("python" . python-mode)
- interpreter-mode-alist)
- python-mode-hook
- '(lambda () (progn
- (set-variable 'py-indent-offset 4)
- (set-variable 'py-smart-indentation nil)
- (set-variable 'indent-tabs-mode nil)
- (define-key python-mode-map "\C-m" 'newline-and-indent)
- (turn-on-eldoc-mode)
- )))
+(autoload 'python-mode "python-mode" "Python Mode." t)
+(add-auto-mode 'python-mode "\\.py\\'")
+(add-auto-mode 'python-mode "\\.py$")
+(add-auto-mode 'python-mode "SConstruct\\'")
+(add-auto-mode 'python-mode "SConscript\\'")
+(add-to-list 'interpreter-mode-alist '("python" . python-mode))
+
+(after 'python-mode
+ (set-variable 'py-indent-offset 4)
+ (set-variable 'py-smart-indentation nil)
+ (set-variable 'indent-tabs-mode nil)
+ (define-key python-mode-map "\C-m" 'newline-and-indent)
+ (turn-on-eldoc-mode)
(defun python-auto-fill-comments-only ()
(auto-fill-mode 1)
(set (make-local-variable 'fill-nobreak-predicate)
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
- (autoload 'pymacs-load "pymacs" nil t)
-
+ (autoload 'pymacs-load "pymacs" nil t))
#+END_SRC
If an =ipython= executable is on the path, then assume that IPython is
But then there are some where it would just be deadly - like org-mode,
gnus, so we have a list of modes where we don't want to see it.
#+BEGIN_SRC emacs-lisp tangle:yes
- (require 'linum)
- (setq linum-format "%3d ")
- (setq linum-mode-inhibit-modes-list '(org-mode
- eshell-mode
- shell-mode
- gnus-group-mode
- gnus-summary-mode
- gnus-article-mode))
+(require 'linum)
+(setq linum-format "%3d ")
+(setq linum-mode-inhibit-modes-list '(org-mode
+ eshell-mode
+ shell-mode
+ gnus-group-mode
+ gnus-summary-mode
+ gnus-article-mode))
- (defadvice linum-on (around linum-on-inhibit-for-modes)
- "Stop the load of linum-mode for some major modes."
- (unless (member major-mode linum-mode-inhibit-modes-list)
- ad-do-it))
+(defadvice linum-on (around linum-on-inhibit-for-modes)
+ "Stop the load of linum-mode for some major modes."
+ (unless (member major-mode linum-mode-inhibit-modes-list)
+ ad-do-it))
- (ad-activate 'linum-on)
- (global-linum-mode 1)
+(ad-activate 'linum-on)
+(global-linum-mode 1)
#+END_SRC
** css
#+BEGIN_SRC emacs-lisp tangle:yes
(autoload 'css-mode "css-mode")
(add-auto-mode 'css-mode "\\.css")
-;;; CSS flymake
-(require 'flymake-css)
-(defun maybe-flymake-css-load ()
- "Activate flymake-css as necessary, but not in derived modes."
- (when (eq major-mode 'css-mode)
- (flymake-css-load)))
-(add-hook 'css-mode-hook 'maybe-flymake-css-load)
-;;; Auto-complete CSS keywords
-(eval-after-load 'auto-complete
- '(progn
- (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
- (add-hook hook 'ac-css-mode-setup))))
+
+(after 'css-mode
+ ;;; CSS flymake
+ (require 'flymake-css)
+ (defun maybe-flymake-css-load ()
+ "Activate flymake-css as necessary, but not in derived modes."
+ (when (eq major-mode 'css-mode)
+ (flymake-css-load)))
+ (add-hook 'css-mode-hook 'maybe-flymake-css-load)
+ ;;; Auto-complete CSS keywords
+ (eval-after-load 'auto-complete
+ '(progn
+ (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
+ (add-hook hook 'ac-css-mode-setup)))))
#+END_SRC
** mmm-mode
Instead of default /html-mode/ I use /html-helper-mode/.
#+BEGIN_SRC emacs-lisp tangle:yes
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
-(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))
+(add-auto-mode 'html-helper-mode "\\.html$")
+(add-auto-mode 'html-helper-mode "\\.asp$")
+(add-auto-mode 'html-helper-mode "\\.phtml$")
+(add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
(defalias 'html-mode 'html-helper-mode)
#+END_SRC
#+BEGIN_SRC emacs-lisp tangle:yes
(autoload 'mingus "mingus-stays-home" nil t)
(global-set-key (kbd "<f6>") 'mingus)
-(setq mingus-dired-add-keys t)
-(setq mingus-mode-always-modeline nil)
-(setq mingus-mode-line-show-elapsed-percentage nil)
-(setq mingus-mode-line-show-volume nil)
-(setq mingus-mpd-config-file "/etc/mpd.conf")
-(setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
-(setq mingus-mpd-root "/share/music/")
+(after 'mingus
+ (setq mingus-dired-add-keys t)
+ (setq mingus-mode-always-modeline nil)
+ (setq mingus-mode-line-show-elapsed-percentage nil)
+ (setq mingus-mode-line-show-volume nil)
+ (setq mingus-mpd-config-file "/etc/mpd.conf")
+ (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
+ (setq mingus-mpd-root "/share/music/"))
#+END_SRC
** sessions
#+END_SRC
** message
#+BEGIN_SRC emacs-lisp tangle:yes
- (require 'message)
- (setq message-kill-buffer-on-exit t)
+(require 'message)
+(setq message-kill-buffer-on-exit t)
#+END_SRC
** gnus
Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
what I want every emacs to know.
-
#+BEGIN_SRC emacs-lisp tangle:yes
;;*** Keyboardmacros
(global-unset-key "\M-n")
(global-set-key "\M-n" 'gnus) ; Start gnus with M-n
+(after 'gnus
+ (jj-init-theme)
+)
#+END_SRC
** url
Crazy way of completion. It looks at the word before point and then
tries to expand it in various ways.
#+BEGIN_SRC emacs-lisp tangle:yes
- (require 'hippie-exp)
- (setq hippie-expand-try-functions-list '(try-expand-dabbrev
- try-expand-dabbrev-all-buffers
- try-expand-dabbrev-from-kill
- try-complete-file-name-partially
- try-complete-file-name
- try-expand-all-abbrevs try-expand-list
- try-expand-line
- try-complete-lisp-symbol-partially
- try-complete-lisp-symbol))
- (global-set-key (kbd "M-/") 'hippie-expand)
+(require 'hippie-exp)
+(setq hippie-expand-try-functions-list '(try-expand-dabbrev
+ try-expand-dabbrev-all-buffers
+ try-expand-dabbrev-from-kill
+ try-complete-file-name-partially
+ try-complete-file-name
+ try-expand-all-abbrevs try-expand-list
+ try-expand-line
+ try-complete-lisp-symbol-partially
+ try-complete-lisp-symbol))
+(global-set-key (kbd "M-/") 'hippie-expand)
#+END_SRC
** yasnippet
[2013-04-27 Sa 23:16]
#+END_SRC
** windmove
[2013-04-21 So 20:27]
-Use shift + arrow keys to switch between visible buffers
+Use hyper + arrow keys to switch between visible buffers
#+BEGIN_SRC emacs-lisp tangle:yes
(require 'windmove)
(windmove-default-keybindings 'hyper)
(require 're-builder)
(setq reb-re-syntax 'string)
#+END_SRC
-
-[2013-04-21 So 20:39]
-
** magit
[2013-04-21 So 20:48]
magit is a mode for interacting with git.
(setq lisp-coding-hook 'lisp-coding-defaults)
(setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
-(eval-after-load "paredit"
+(after "paredit"
'(diminish 'paredit-mode " π"))
(setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
-(eval-after-load "elisp-slime-nav"
+(after "elisp-slime-nav"
'(diminish 'elisp-slime-nav-mode))
-(eval-after-load "rainbow-mode"
+(after "rainbow-mode"
'(diminish 'rainbow-mode))
-(eval-after-load "eldoc"
+(after "eldoc"
'(diminish 'eldoc-mode))
#+END_SRC
readable/editable without getting a big headache.
#+BEGIN_SRC emacs-lisp tangle:yes
(require 'yaml-mode)
-(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
+(add-auto-mode 'yaml-mode "\\.yml$")
+(add-auto-mode 'yaml-mode "\\.yaml$")
(add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
** nxml
[2013-05-22 Wed 22:02]
-
nxml-mode is a major mode for editing XML.
#+BEGIN_SRC emacs-lisp tangle:yes
(add-auto-mode
(fset 'xml-mode 'nxml-mode)
(setq nxml-slash-auto-complete-flag t)
-
;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
(defun pp-xml-region (begin end)
"Pretty format XML markup in region. The function inserts
(add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
(add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
))
-(add-auto-mode 'html-mode "\\.(jsp|tmpl)\\'")
#+END_SRC
** ruby
[2013-05-22 Wed 22:33]
Programming in ruby...
+*** Auto-modes
#+BEGIN_SRC emacs-lisp tangle:yes
(add-auto-mode 'ruby-mode
"Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
"\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
"\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
+#+END_SRC
-(setq ruby-use-encoding-map nil)
-
-(eval-after-load 'ruby-mode
- '(progn
- (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
- (define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)))
-
-;; Stupidly the non-bundled ruby-mode isn't a derived mode of
-;; prog-mode: we run the latter's hooks anyway in that case.
-(add-hook 'ruby-mode-hook
- (lambda ()
- (unless (derived-mode-p 'prog-mode)
- (run-hooks 'prog-mode-hook))))
-
-;;; ERB
-(defun sanityinc/ensure-mmm-erb-loaded ()
- (require 'mmm-erb))
-
-(require 'derived)
-
-(defun sanityinc/set-up-mode-for-erb (mode)
- (add-hook (derived-mode-hook-name mode) 'sanityinc/ensure-mmm-erb-loaded)
- (mmm-add-mode-ext-class mode "\\.erb\\'" 'erb))
-
-(let ((html-erb-modes '(html-mode html-erb-mode nxml-mode)))
- (dolist (mode html-erb-modes)
- (sanityinc/set-up-mode-for-erb mode)
- (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-js)
- (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css)))
-
-(mapc 'sanityinc/set-up-mode-for-erb
- '(coffee-mode js-mode js2-mode js3-mode markdown-mode textile-mode))
-
-(mmm-add-mode-ext-class 'html-erb-mode "\\.jst\\.ejs\\'" 'ejs)
-
-(add-auto-mode 'html-erb-mode "\\.rhtml\\'" "\\.html\\.erb\\'")
-(add-to-list 'auto-mode-alist '("\\.jst\\.ejs\\'" . html-erb-mode))
-(mmm-add-mode-ext-class 'yaml-mode "\\.yaml\\'" 'erb)
+*** Config
+#+BEGIN_SRC emacs-lisp tangle:yes
+(after 'ruby-mode
+ (message "ruby has been loaded")
+ (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
+ (define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)
-(dolist (mode (list 'js-mode 'js2-mode 'js3-mode))
- (mmm-add-mode-ext-class mode "\\.js\\.erb\\'" 'erb))
+ (require 'ruby-hash-syntax)
+ (require 'inf-ruby)
+ (setq ruby-use-encoding-map nil)
+ ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
+ ;; prog-mode: we run the latter's hooks anyway in that case.
+ (add-hook 'ruby-mode-hook
+ (lambda ()
+ (unless (derived-mode-p 'prog-mode)
+ (run-hooks 'prog-mode-hook))))
+ )
#+END_SRC
** emms
EMMS is the Emacs Multimedia System.
-#+BEGIN_SRC emacs-lisp tangle:yes
+#+BEGIN_SRC emacs-lisp tangle:no
(require 'emms-source-file)
(require 'emms-source-playlist)
(require 'emms-info)
;;(define-key global-map (kbd "C-c C-f") 'yafolding-toggle-all)
(define-key global-map (kbd "C-c C-f") 'yafolding-toggle-all-by-current-level)
#+END_SRC
+** icomplete
+Incremental mini-buffer completion preview: Type in the minibuffer,
+list of matching commands is echoed
+#+BEGIN_SRC emacs-lisp tangle:yes
+(icomplete-mode 99)
+#+END_SRC
+
* Thats it
And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
which then may load more files.
(dotimes (i num-lines)
(mc/create-fake-cursor-at-point)
(ecase direction
- (forwards (loop do (next-line 1 nil)
+ (forwards (loop do (next-logical-line 1 nil)
while (mc/all-fake-cursors (point) (1+ (point)))))
- (backwards (loop do (previous-line 1 nil)
+ (backwards (loop do (previous-logical-line 1 nil)
while (mc/all-fake-cursors (point) (1+ (point))))))))
;;;###autoload
(mc/maybe-multiple-cursors-mode))
;;;###autoload
-(defun mc/unmark-next-like-this (arg)
+(defun mc/unmark-next-like-this ()
"Deselect next part of the buffer matching the currently active region."
(interactive)
(mc/mark-next-like-this -1))
;;;###autoload
-(defun mc/unmark-previous-like-this (arg)
+(defun mc/unmark-previous-like-this ()
"Deselect prev part of the buffer matching the currently active region."
(interactive)
(mc/mark-previous-like-this -1))
+;;;###autoload
+(defun mc/skip-to-next-like-this ()
+ "Skip the current one and select the next part of the buffer matching the currently active region."
+ (interactive)
+ (mc/mark-next-like-this 0))
+
+;;;###autoload
+(defun mc/skip-to-previous-like-this ()
+ "Skip the current one and select the prev part of the buffer matching the currently active region."
+ (interactive)
+ (mc/mark-previous-like-this 0))
+
;;;###autoload
(defun mc/mark-all-like-this ()
"Find and mark all the parts of the buffer matching the currently active region"
(interactive "r")
(let ((search (read-from-minibuffer "Mark all in region: "))
(case-fold-search nil))
- (mc/remove-fake-cursors)
- (goto-char beg)
- (while (search-forward search end t)
- (push-mark (match-beginning 0))
- (mc/create-fake-cursor-at-point))
- (let ((first (mc/furthest-cursor-before-point)))
- (if (not first)
- (error "Search failed for %S" search)
- (mc/pop-state-from-overlay first))))
- (if (> (mc/num-cursors) 1)
- (multiple-cursors-mode 1)
- (multiple-cursors-mode 0)))
+ (if (string= search "")
+ (message "Mark aborted")
+ (progn
+ (mc/remove-fake-cursors)
+ (goto-char beg)
+ (while (search-forward search end t)
+ (push-mark (match-beginning 0))
+ (mc/create-fake-cursor-at-point))
+ (let ((first (mc/furthest-cursor-before-point)))
+ (if (not first)
+ (error "Search failed for %S" search)
+ (mc/pop-state-from-overlay first)))
+ (if (> (mc/num-cursors) 1)
+ (multiple-cursors-mode 1)
+ (multiple-cursors-mode 0))))))
+
+(when (not (fboundp 'set-temporary-overlay-map))
+ ;; Backport this function from newer emacs versions
+ (defun set-temporary-overlay-map (map &optional keep-pred)
+ "Set a new keymap that will only exist for a short period of time.
+The new keymap to use must be given in the MAP variable. When to
+remove the keymap depends on user input and KEEP-PRED:
+
+- if KEEP-PRED is nil (the default), the keymap disappears as
+ soon as any key is pressed, whether or not the key is in MAP;
+
+- if KEEP-PRED is t, the keymap disappears as soon as a key *not*
+ in MAP is pressed;
+
+- otherwise, KEEP-PRED must be a 0-arguments predicate that will
+ decide if the keymap should be removed (if predicate returns
+ nil) or kept (otherwise). The predicate will be called after
+ each key sequence."
+
+ (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
+ (overlaysym (make-symbol "t"))
+ (alist (list (cons overlaysym map)))
+ (clearfun
+ `(lambda ()
+ (unless ,(cond ((null keep-pred) nil)
+ ((eq t keep-pred)
+ `(eq this-command
+ (lookup-key ',map
+ (this-command-keys-vector))))
+ (t `(funcall ',keep-pred)))
+ (remove-hook 'pre-command-hook ',clearfunsym)
+ (setq emulation-mode-map-alists
+ (delq ',alist emulation-mode-map-alists))))))
+ (set overlaysym overlaysym)
+ (fset clearfunsym clearfun)
+ (add-hook 'pre-command-hook clearfunsym)
+
+ (push alist emulation-mode-map-alists))))
;;;###autoload
(defun mc/mark-more-like-this-extended ()
"Like mark-more-like-this, but then lets you adjust with arrows key.
-The actual adjustment made depends on the final component of the
-key-binding used to invoke the command, with all modifiers removed:
-
- <up> Mark previous like this
- <down> Mark next like this
- <left> If last was previous, skip it
- If last was next, remove it
- <right> If last was next, skip it
- If last was previous, remove it
-
-Then, continue to read input events and further add or move marks
-as long as the input event read (with all modifiers removed)
-is one of the above."
+The adjustments work like this:
+
+ <up> Mark previous like this and set direction to 'up
+ <down> Mark next like this and set direction to 'down
+
+If direction is 'up:
+
+ <left> Skip past the cursor furthest up
+ <right> Remove the cursor furthest up
+
+If direction is 'down:
+
+ <left> Remove the cursor furthest down
+ <right> Skip past the cursor furthest down
+
+The bindings for these commands can be changed. See `mc/mark-more-like-this-extended-keymap'."
+ (interactive)
+ (mc/mmlte--down)
+ (set-temporary-overlay-map mc/mark-more-like-this-extended-keymap t))
+
+(defvar mc/mark-more-like-this-extended-direction nil
+ "When using mc/mark-more-like-this-extended are we working on the next or previous cursors?")
+
+(make-variable-buffer-local 'mc/mark-more-like-this-extended)
+
+(defun mc/mmlte--message ()
+ (if (eq mc/mark-more-like-this-extended-direction 'up)
+ (message "<up> to mark previous, <left> to skip, <right> to remove, <down> to mark next")
+ (message "<down> to mark next, <right> to skip, <left> to remove, <up> to mark previous")))
+
+(defun mc/mmlte--up ()
+ (interactive)
+ (mc/mark-previous-like-this 1)
+ (setq mc/mark-more-like-this-extended-direction 'up)
+ (mc/mmlte--message))
+
+(defun mc/mmlte--down ()
+ (interactive)
+ (mc/mark-next-like-this 1)
+ (setq mc/mark-more-like-this-extended-direction 'down)
+ (mc/mmlte--message))
+
+(defun mc/mmlte--left ()
+ (interactive)
+ (if (eq mc/mark-more-like-this-extended-direction 'down)
+ (mc/unmark-next-like-this)
+ (mc/skip-to-previous-like-this))
+ (mc/mmlte--message))
+
+(defun mc/mmlte--right ()
(interactive)
- (let ((first t)
- (ev last-command-event)
- (cmd 'mc/mark-next-like-this)
- (arg 1)
- last echo-keystrokes)
- (while cmd
- (let ((base (event-basic-type ev)))
- (cond ((eq base 'left)
- (if (eq last 'mc/mark-previous-like-this)
- (setq cmd last arg 0)
- (setq cmd 'mc/mark-next-like-this arg -1)))
- ((eq base 'up)
- (setq cmd 'mc/mark-previous-like-this arg 1))
- ((eq base 'right)
- (if (eq last 'mc/mark-next-like-this)
- (setq cmd last arg 0)
- (setq cmd 'mc/mark-previous-like-this arg -1)))
- ((eq base 'down)
- (setq cmd 'mc/mark-next-like-this arg 1))
- (first
- (setq cmd 'mc/mark-next-like-this arg 1))
- (t
- (setq cmd nil))))
- (when cmd
- (ignore-errors
- (funcall cmd arg))
- (setq first nil last cmd)
- (setq ev (read-event "Use arrow keys for more marks: "))))
- (push ev unread-command-events)))
+ (if (eq mc/mark-more-like-this-extended-direction 'up)
+ (mc/unmark-previous-like-this)
+ (mc/skip-to-next-like-this))
+ (mc/mmlte--message))
+
+(defvar mc/mark-more-like-this-extended-keymap (make-sparse-keymap))
+
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<up>") 'mc/mmlte--up)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<down>") 'mc/mmlte--down)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<left>") 'mc/mmlte--left)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<right>") 'mc/mmlte--right)
(defvar mc--restrict-mark-all-to-symbols nil)
(when (<= (mc/num-cursors) before)
(mc/mark-all-like-this))))))
+;;;###autoload
+(defun mc/mark-all-dwim (arg)
+ "Tries even harder to guess what you want to mark all of.
+
+If the region is active and spans multiple lines, it will behave
+as if `mc/mark-all-in-region'. With the prefix ARG, it will call
+`mc/edit-lines' instead.
+
+If the region is inactive or on a single line, it will behave like
+`mc/mark-all-like-this-dwim'."
+ (interactive "P")
+ (if (and (use-region-p)
+ (not (> (mc/num-cursors) 1))
+ (not (= (line-number-at-pos (region-beginning))
+ (line-number-at-pos (region-end)))))
+ (if arg
+ (call-interactively 'mc/edit-lines)
+ (call-interactively 'mc/mark-all-in-region))
+ (progn
+ (setq this-command 'mc/mark-all-like-this-dwim)
+ (mc/mark-all-like-this-dwim arg))))
+
(defun mc--in-defun ()
(bounds-of-thing-at-point 'defun))
--- /dev/null
+;;; mc-mark-pop.el --- Pop cursors off of the mark stack
+
+(require 'multiple-cursors-core)
+
+;;;###autoload
+(defun mc/mark-pop ()
+ "Add a cursor at the current point, pop off mark ring and jump
+to the popped mark."
+ (interactive)
+ ;; If the mark happens to be at the current point, just pop that one off.
+ (while (eql (mark) (point))
+ (pop-mark))
+ (mc/create-fake-cursor-at-point)
+ (exchange-point-and-mark)
+ (pop-mark)
+ (mc/maybe-multiple-cursors-mode))
+
+;; A good key binding for this feature is perhaps "C-S-p" ('p' for pop).
+
+(provide 'mc-mark-pop)
+
+;;; mc-mark-pop.el ends here
--- /dev/null
+;;; multiple-cursors-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
+\f
+;;;### (autoloads nil "mc-edit-lines" "mc-edit-lines.el" (21045 37519
+;;;;;; 709674 618000))
+;;; Generated autoloads from mc-edit-lines.el
+
+(autoload 'mc/edit-lines "mc-edit-lines" "\
+Add one cursor to each line of the active region.
+Starts from mark and moves in straight down or up towards the
+line point is on.
+
+\(fn)" t nil)
+
+(autoload 'mc/edit-ends-of-lines "mc-edit-lines" "\
+Add one cursor to the end of each line in the active region.
+
+\(fn)" t nil)
+
+(autoload 'mc/edit-beginnings-of-lines "mc-edit-lines" "\
+Add one cursor to the beginning of each line in the active region.
+
+\(fn)" t nil)
+
+;;;***
+\f
+;;;### (autoloads nil "mc-mark-more" "mc-mark-more.el" (21045 37519
+;;;;;; 705674 598000))
+;;; Generated autoloads from mc-mark-more.el
+
+(autoload 'mc/mark-next-like-this "mc-mark-more" "\
+Find and mark the next part of the buffer matching the currently active region
+With negative ARG, delete the last one instead.
+With zero ARG, skip the last one and mark next.
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-next-word-like-this "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-next-symbol-like-this "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-previous-like-this "mc-mark-more" "\
+Find and mark the previous part of the buffer matching the currently active region
+With negative ARG, delete the last one instead.
+With zero ARG, skip the last one and mark next.
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-previous-word-like-this "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-previous-symbol-like-this "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-next-lines "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-previous-lines "mc-mark-more" "\
+
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/unmark-next-like-this "mc-mark-more" "\
+Deselect next part of the buffer matching the currently active region.
+
+\(fn)" t nil)
+
+(autoload 'mc/unmark-previous-like-this "mc-mark-more" "\
+Deselect prev part of the buffer matching the currently active region.
+
+\(fn)" t nil)
+
+(autoload 'mc/skip-to-next-like-this "mc-mark-more" "\
+Skip the current one and select the next part of the buffer matching the currently active region.
+
+\(fn)" t nil)
+
+(autoload 'mc/skip-to-previous-like-this "mc-mark-more" "\
+Skip the current one and select the prev part of the buffer matching the currently active region.
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-like-this "mc-mark-more" "\
+Find and mark all the parts of the buffer matching the currently active region
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-words-like-this "mc-mark-more" "\
+
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-symbols-like-this "mc-mark-more" "\
+
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-in-region "mc-mark-more" "\
+Find and mark all the parts in the region matching the given search
+
+\(fn BEG END)" t nil)
+
+(autoload 'mc/mark-more-like-this-extended "mc-mark-more" "\
+Like mark-more-like-this, but then lets you adjust with arrows key.
+The adjustments work like this:
+
+ <up> Mark previous like this and set direction to 'up
+ <down> Mark next like this and set direction to 'down
+
+If direction is 'up:
+
+ <left> Skip past the cursor furthest up
+ <right> Remove the cursor furthest up
+
+If direction is 'down:
+
+ <left> Remove the cursor furthest down
+ <right> Skip past the cursor furthest down
+
+The bindings for these commands can be changed. See `mc/mark-more-like-this-extended-keymap'.
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-like-this-dwim "mc-mark-more" "\
+Tries to guess what you want to mark all of.
+Can be pressed multiple times to increase selection.
+
+With prefix, it behaves the same as original `mc/mark-all-like-this'
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-all-dwim "mc-mark-more" "\
+Tries even harder to guess what you want to mark all of.
+
+If the region is active and spans multiple lines, it will behave
+as if `mc/mark-all-in-region'. With the prefix ARG, it will call
+`mc/edit-lines' instead.
+
+If the region is inactive or on a single line, it will behave like
+`mc/mark-all-like-this-dwim'.
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/mark-all-like-this-in-defun "mc-mark-more" "\
+Mark all like this in defun.
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-words-like-this-in-defun "mc-mark-more" "\
+Mark all words like this in defun.
+
+\(fn)" t nil)
+
+(autoload 'mc/mark-all-symbols-like-this-in-defun "mc-mark-more" "\
+Mark all symbols like this in defun.
+
+\(fn)" t nil)
+
+(autoload 'mc/add-cursor-on-click "mc-mark-more" "\
+Add a cursor where you click.
+
+\(fn EVENT)" t nil)
+
+(autoload 'mc/mark-sgml-tag-pair "mc-mark-more" "\
+Mark the tag we're in and its pair for renaming.
+
+\(fn)" t nil)
+
+;;;***
+\f
+;;;### (autoloads nil "mc-mark-pop" "mc-mark-pop.el" (21045 37519
+;;;;;; 709674 618000))
+;;; Generated autoloads from mc-mark-pop.el
+
+(autoload 'mc/mark-pop "mc-mark-pop" "\
+Add a cursor at the current point, pop off mark ring and jump
+to the popped mark.
+
+\(fn)" t nil)
+
+;;;***
+\f
+;;;### (autoloads nil "mc-separate-operations" "mc-separate-operations.el"
+;;;;;; (21045 37519 709674 618000))
+;;; Generated autoloads from mc-separate-operations.el
+
+(autoload 'mc/insert-numbers "mc-separate-operations" "\
+Insert increasing numbers for each cursor, starting at 0 or ARG.
+
+\(fn ARG)" t nil)
+
+(autoload 'mc/reverse-regions "mc-separate-operations" "\
+
+
+\(fn)" t nil)
+
+(autoload 'mc/sort-regions "mc-separate-operations" "\
+
+
+\(fn)" t nil)
+
+;;;***
+\f
+;;;### (autoloads nil "rectangular-region-mode" "rectangular-region-mode.el"
+;;;;;; (21045 37519 709674 618000))
+;;; Generated autoloads from rectangular-region-mode.el
+
+(autoload 'set-rectangular-region-anchor "rectangular-region-mode" "\
+Anchors the rectangular region at point.
+
+Think of this one as `set-mark' except you're marking a rectangular region. It is
+an exceedingly quick way of adding multiple cursors to multiple lines.
+
+\(fn)" t nil)
+
+;;;***
+\f
+;;;### (autoloads nil nil ("mc-cycle-cursors.el" "multiple-cursors-core.el"
+;;;;;; "multiple-cursors-pkg.el" "multiple-cursors.el") (21045 37519
+;;;;;; 715378 765000))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; multiple-cursors-autoloads.el ends here
(defmacro mc/add-fake-cursor-to-undo-list (&rest forms)
"Make sure point is in the right place when undoing"
(let ((uc (make-symbol "undo-cleaner")))
- `(let ((,uc (cons 'apply (cons 'deactivate-cursor-after-undo (list id)))))
- (setq buffer-undo-list (cons ,uc buffer-undo-list))
- ,@forms
- (if (eq ,uc (car buffer-undo-list)) ;; if nothing has been added to the undo-list
- (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the cleaner right off again
- (setq buffer-undo-list ;; otherwise add a function to activate this cursor
- (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list))))))
+ `(let ((,uc (cons 'apply (cons 'deactivate-cursor-after-undo (list id)))))
+ (setq buffer-undo-list (cons ,uc buffer-undo-list))
+ ,@forms
+ (if (eq ,uc (car buffer-undo-list)) ;; if nothing has been added to the undo-list
+ (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the cleaner right off again
+ (setq buffer-undo-list ;; otherwise add a function to activate this cursor
+ (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list))))))
(defun mc/all-fake-cursors (&optional start end)
(remove-if-not 'mc/fake-cursor-p
(defmacro mc/save-excursion (&rest forms)
"Saves and restores all the state that multiple-cursors cares about."
(let ((cs (make-symbol "current-state")))
- `(let ((,cs (mc/store-current-state-in-overlay
- (make-overlay (point) (point) nil nil t))))
- (overlay-put ,cs 'type 'original-cursor)
- (save-excursion ,@forms)
- (mc/pop-state-from-overlay ,cs))))
+ `(let ((,cs (mc/store-current-state-in-overlay
+ (make-overlay (point) (point) nil nil t))))
+ (overlay-put ,cs 'type 'original-cursor)
+ (save-excursion ,@forms)
+ (mc/pop-state-from-overlay ,cs))))
(defun mc--compare-by-overlay-start (o1 o2)
(< (overlay-start o1) (overlay-start o2)))
(defmacro mc/for-each-cursor-ordered (&rest forms)
"Runs the body for each cursor, fake and real, bound to the name cursor"
(let ((rci (make-symbol "real-cursor-id")))
- `(let ((,rci (overlay-get (mc/create-fake-cursor-at-point) 'mc-id)))
- (mapc #'(lambda (cursor)
- (when (mc/fake-cursor-p cursor)
- ,@forms))
- (sort (overlays-in (point-min) (point-max)) 'mc--compare-by-overlay-start))
- (mc/pop-state-from-overlay (mc/cursor-with-id ,rci)))))
+ `(let ((,rci (overlay-get (mc/create-fake-cursor-at-point) 'mc-id)))
+ (mapc #'(lambda (cursor)
+ (when (mc/fake-cursor-p cursor)
+ ,@forms))
+ (sort (overlays-in (point-min) (point-max)) 'mc--compare-by-overlay-start))
+ (mc/pop-state-from-overlay (mc/cursor-with-id ,rci)))))
(defmacro mc/save-window-scroll (&rest forms)
"Saves and restores the window scroll position"
(let ((p (make-symbol "p"))
(s (make-symbol "start"))
(h (make-symbol "hscroll")))
- `(let ((,p (set-marker (make-marker) (point)))
- (,s (set-marker (make-marker) (window-start)))
- (,h (window-hscroll)))
- ,@forms
- (goto-char ,p)
- (set-window-start nil ,s t)
- (set-window-hscroll nil ,h)
- (set-marker ,p nil)
- (set-marker ,s nil))))
+ `(let ((,p (set-marker (make-marker) (point)))
+ (,s (set-marker (make-marker) (window-start)))
+ (,h (window-hscroll)))
+ ,@forms
+ (goto-char ,p)
+ (set-window-start nil ,s t)
+ (set-window-hscroll nil ,h)
+ (set-marker ,p nil)
+ (set-marker ,s nil))))
(defun mc/make-cursor-overlay-at-eol (pos)
"Create overlay to look like cursor at end of line."
(overlay-put overlay 'type 'additional-region)
overlay))
-(defvar mc/cursor-specific-vars '(autopair-action
+(defvar mc/cursor-specific-vars '(transient-mark-mode
+ kill-ring
+ kill-ring-yank-pointer
+ mark-ring
+ mark-active
+ yank-undo-function
+ kill-ring-yank-pointer
+ autopair-action
autopair-wrap-action
- transient-mark-mode
er/history)
"A list of vars that need to be tracked on a per-cursor basis.")
(defun mc/store-current-state-in-overlay (o)
"Store relevant info about point and mark in the given overlay."
(overlay-put o 'point (set-marker (make-marker) (point)))
- (overlay-put o 'kill-ring kill-ring)
- (overlay-put o 'kill-ring-yank-pointer kill-ring-yank-pointer)
(overlay-put o 'mark (set-marker (make-marker) (mark)))
- (overlay-put o 'mark-ring mark-ring)
- (overlay-put o 'mark-active mark-active)
- (overlay-put o 'yank-undo-function yank-undo-function)
- (overlay-put o 'kill-ring-yank-pointer kill-ring-yank-pointer)
(dolist (var mc/cursor-specific-vars)
(when (boundp var) (overlay-put o var (symbol-value var))))
o)
(defun mc/restore-state-from-overlay (o)
"Restore point and mark from stored info in the given overlay."
(goto-char (overlay-get o 'point))
- (setq kill-ring (overlay-get o 'kill-ring))
- (setq kill-ring-yank-pointer (overlay-get o 'kill-ring-yank-pointer))
(set-marker (mark-marker) (overlay-get o 'mark))
- (setq mark-ring (overlay-get o 'mark-ring))
- (setq mark-active (overlay-get o 'mark-active))
- (setq yank-undo-function (overlay-get o 'yank-undo-function))
- (setq kill-ring-yank-pointer (overlay-get o 'kill-ring-yank-pointer))
(dolist (var mc/cursor-specific-vars)
(when (boundp var) (set var (overlay-get o var)))))
remapping based on state. So a command that changes the state will afterwards
not be recognized through the command-remapping lookup."
(unless mc--executing-command-for-fake-cursor
- (setq mc--this-command (or (command-remapping this-original-command)
- this-original-command))))
+ (let ((cmd (or (command-remapping this-original-command)
+ this-original-command)))
+ (setq mc--this-command (and (not (eq cmd 'god-mode-self-insert))
+ cmd)))))
(defun mc/execute-this-command-for-all-cursors ()
"Wrap around `mc/execute-this-command-for-all-cursors-1' to protect hook."
(if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
(multiple-cursors-mode 0)
-
(when this-original-command
(let ((original-command (or mc--this-command
(command-remapping this-original-command)
"Keymap while multiple cursors are active.
Main goal of the keymap is to rebind C-g and <return> to conclude
multiple cursors editing.")
-(if mc/keymap
- nil
+(unless mc/keymap
(setq mc/keymap (make-sparse-keymap))
(define-key mc/keymap (kbd "C-g") 'mc/keyboard-quit)
(define-key mc/keymap (kbd "<return>") 'multiple-cursors-mode)
(when (fboundp 'phi-search)
- (define-key mc/keymap (kbd "C-s") 'phi-search)))
+ (define-key mc/keymap (kbd "C-s") 'phi-search))
+ (when (fboundp 'phi-search-backward)
+ (define-key mc/keymap (kbd "C-r") 'phi-search-backward)))
-(defun mc--all-equal (entries)
- "Are all these entries equal?"
- (let ((first (car entries))
+(defun mc--all-equal (list)
+ "Are all the items in LIST equal?"
+ (let ((first (car list))
(all-equal t))
- (while (and all-equal entries)
- (setq all-equal (equal first (car entries)))
- (setq entries (cdr entries)))
+ (while (and all-equal list)
+ (setq all-equal (equal first (car list)))
+ (setq list (cdr list)))
all-equal))
(defun mc--kill-ring-entries ()
(unless (mc--all-equal entries)
(setq killed-rectangle entries))))
-(defvar mc/unsupported-minor-modes '(auto-complete-mode)
+(defvar mc/unsupported-minor-modes '(auto-complete-mode flyspell-mode)
"List of minor-modes that does not play well with multiple-cursors.
They are temporarily disabled when multiple-cursors are active.")
mc/mark-all-words-like-this-in-defun
mc/mark-all-symbols-like-this-in-defun
mc/mark-all-like-this-dwim
+ mc/mark-all-dwim
mc/mark-sgml-tag-pair
mc/insert-numbers
mc/sort-regions
mc/cycle-forward
mc/cycle-backward
mc/add-cursor-on-click
+ mc/mark-pop
+ mc/add-cursors-to-all-matches
+ mc/mmlte--left
+ mc/mmlte--right
+ mc/mmlte--up
+ mc/mmlte--down
+ mc/unmark-next-like-this
+ mc/unmark-previous-like-this
+ mc/skip-to-next-like-this
+ mc/skip-to-previous-like-this
rrm/switch-to-multiple-cursors
save-buffer
ido-exit-minibuffer
-(define-package "multiple-cursors" "1.2.1"
- "Multiple cursors for Emacs.")
+(define-package "multiple-cursors" "20130913.1148" "Multiple cursors for Emacs. [github]" 'nil)
+
-;;; multiple-cursors.el --- An experiment in multiple cursors for emacs.
+;;; multiple-cursors.el --- Multiple cursors for emacs.
-;; Copyright (C) 2012 Magnar Sveen
+;; Copyright (C) 2012-2013 Magnar Sveen
;; Author: Magnar Sveen <magnars@gmail.com>
+;; Version: 1.2.2
;; Keywords: editing cursors
;; This program is free software; you can redistribute it and/or modify
(require 'mc-edit-lines)
(require 'mc-cycle-cursors)
(require 'mc-mark-more)
+(require 'mc-mark-pop)
(require 'rectangular-region-mode)
(require 'mc-separate-operations)
(defun rrm/repaint ()
"Start from the anchor and draw a rectangle between it and point."
- (rrm/remove-rectangular-region-overlays)
- (let* ((annoying-arrows-mode nil)
- (point-column (current-column))
- (point-line (line-number-at-pos))
- (anchor-column (save-excursion (goto-char rrm/anchor) (current-column)))
- (anchor-line (save-excursion (goto-char rrm/anchor) (line-number-at-pos)))
- (left-column (if (< point-column anchor-column) point-column anchor-column))
- (right-column (if (> point-column anchor-column) point-column anchor-column))
- (navigation-step (if (< point-line anchor-line) 1 -1)))
- (move-to-column anchor-column)
- (set-mark (point))
- (move-to-column point-column)
- (mc/save-excursion
- (while (not (= anchor-line (line-number-at-pos)))
- (forward-line navigation-step)
- (move-to-column anchor-column)
- (when (= anchor-column (current-column))
- (set-mark (point))
- (move-to-column point-column)
- (when (= point-column (current-column))
- (mc/create-fake-cursor-at-point)))))))
+ (if (not rectangular-region-mode)
+ (remove-hook 'post-command-hook 'rrm/repaint t)
+ ;; else
+ (rrm/remove-rectangular-region-overlays)
+ (let* ((annoying-arrows-mode nil)
+ (point-column (current-column))
+ (point-line (line-number-at-pos))
+ (anchor-column (save-excursion (goto-char rrm/anchor) (current-column)))
+ (anchor-line (save-excursion (goto-char rrm/anchor) (line-number-at-pos)))
+ (left-column (if (< point-column anchor-column) point-column anchor-column))
+ (right-column (if (> point-column anchor-column) point-column anchor-column))
+ (navigation-step (if (< point-line anchor-line) 1 -1)))
+ (move-to-column anchor-column)
+ (set-mark (point))
+ (move-to-column point-column)
+ (mc/save-excursion
+ (while (not (= anchor-line (line-number-at-pos)))
+ (forward-line navigation-step)
+ (move-to-column anchor-column)
+ (when (= anchor-column (current-column))
+ (set-mark (point))
+ (move-to-column point-column)
+ (when (= point-column (current-column))
+ (mc/create-fake-cursor-at-point))))))))
(defun rrm/switch-to-multiple-cursors (&rest forms)
"Switch from rectangular-region-mode to multiple-cursors-mode."