浏览代码

Add mmv and disable visible-mark

master
10sr 4 年前
父节点
当前提交
4c6506f20f
签署人:: 10sr GPG 密钥 ID: C384BB17CBB19347
共有 1 个文件被更改,包括 55 次插入3 次删除
  1. +55
    -3
      emacs.el

+ 55
- 3
emacs.el 查看文件

@@ -530,8 +530,9 @@ Otherwize hook it."
(run-with-idle-timer 10 t
(lambda ()
(push-mark)
(when (fboundp 'visible-mark-move-overlays)
(visible-mark-move-overlays))))
;; (when (fboundp 'visible-mark-move-overlays)
;; (visible-mark-move-overlays))
))

(when (fboundp 'back-button-mode)
(back-button-mode 1))
@@ -555,7 +556,8 @@ THEM are function and its args."
:around
'visible-mark-move-overlays--avoid-disappear)

(global-visible-mark-mode 1))
;; (global-visible-mark-mode 1)
)

;; visible-mark-mode
;; visible-mark-overlays
@@ -2917,6 +2919,56 @@ Any output will be written to current buffer."
(add-hook 'post-command-hook
'highlight-mark-post-command)

;;;;;;;;;;;;;;
;; mmv
;; https://www.emacswiki.org/emacs/MakingMarkVisible

;;;; Make the mark visible, and the visibility toggleable. ('mmv' means 'make
;;;; mark visible'.) By Patrick Gundlach, Teemu Leisti, and Stefan.

(defface mmv-face
'((t :background "maroon2" :foreground "white"))
"Face used for showing the mark's position.")

(defvar-local mmv-mark-overlay nil
"The overlay for showing the mark's position.")

(defvar-local mmv-is-mark-visible t
"The overlay is visible only when this variable's value is t.")

(defun mmv-draw-mark (&rest _)
"Make the mark's position stand out by means of a one-character-long overlay.
If the value of variable `mmv-is-mark-visible' is nil, the mark will be
invisible."
(unless mmv-mark-overlay
(setq mmv-mark-overlay (make-overlay 0 0 nil t))
(overlay-put mmv-mark-overlay 'face 'mmv-face))
(let ((mark-position (mark t)))
(cond
((null mark-position) (delete-overlay mmv-mark-overlay))
((and (< mark-position (point-max))
(not (eq ?\n (char-after mark-position))))
(overlay-put mmv-mark-overlay 'after-string nil)
(move-overlay mmv-mark-overlay mark-position (1+ mark-position)))
(t
;; This branch is called when the mark is at the end of a line or at the
;; end of the buffer. We use a bit of trickery to avoid the higlight
;; extending from the mark all the way to the right end of the frame.
(overlay-put mmv-mark-overlay 'after-string
(propertize " " 'face (overlay-get mmv-mark-overlay 'face)))
(move-overlay mmv-mark-overlay mark-position mark-position)))))

(add-hook 'pre-redisplay-functions #'mmv-draw-mark)

(defun mmv-toggle-mark-visibility ()
"Toggles the mark's visiblity and redraws it (whether invisible or visible)."
(interactive)
(setq mmv-is-mark-visible (not mmv-is-mark-visible))
(if mmv-is-mark-visible
(set-face-attribute 'mmv-face nil :background "maroon2" :foreground "white")
(set-face-attribute 'mmv-face nil :background 'unspecified :foreground 'unspecified))
(mmv-draw-mark))


;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)


正在加载...
取消
保存