私は、hl-lineがバッファの最後の行を残りの行に拡張できるように、emacs lispの次のビットを書いています。
問題は、これは起動後に(eval-buffer)を使用していて、私の.emacsファイルの中に保存していない場合にのみ有効です。
また、linum.elを変更して、カーソルが置かれているすべての行が行番号を表示するようにしました(emacs-wikiの関連部分に基づいて)。
しかしながら、
私はこのような困難を引き起こす可能性があるとは思っていません。
基本的に私は現在のハイライトラインを現代編集者のように振舞うようにしようとしています。
(defvar-local hl-line-after-cursor nil
"Overlay used by Global-Hl-Line mode to highlight the current line.")
(defun my-hl-line-after-current-line()
(if (eq (line-end-position) (point-max))
(progn
(setq hl-line-after-cursor (make-overlay (line-end-position) (line-end-position)))
(overlay-put hl-line-after-cursor 'after-string
(propertize (make-string (- (- (window-text-width) (- (line-end-position) (line-beginning-position))) 2) (string-to-char " "))
'face hl-line-face 'cursor 1))
(move-overlay hl-line-after-cursor (line-end-position) (line-end-position))
)))
(defun my-hl-line-after-unhighlight ()
"Deactivate the Hl-Line overlay on the current line."
(when hl-line-after-cursor
(delete-overlay hl-line-after-cursor)))
(add-hook 'pre-command-hook #'my-hl-line-after-unhighlight nil t)
(add-hook 'post-command-hook #'my-hl-line-after-current-line nil t)
私のinitファイル
(debug)
(setq user-full-name "YOUR NAME")
(setq user-mail-address "YOUR EMAIL ADDRESS")
;;
;; Basic Setup
;;
(prefer-coding-system 'utf-8)
;; Shorten yes-or-no prompts
(fset 'yes-or-no-p 'y-or-n-p)
;; This code stashes backups in ~/.emacs.d/backups
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
;; This code removes the ugly tool bar
(tool-bar-mode -1)
;; Matching parenthesis highlight
(show-paren-mode 1)
;; Show line numbers
(global-linum-mode 1)
;; Set window title to full file name
(setq frame-title-format '("Emacs @ " system-name ": %b %+%+ %f"))
;; Set up smooth scrolling
(setq redisplay-dont-pause t
scroll-margin 1
scroll-step 1
scroll-conservatively 10000
scroll-preserve-screen-position 1)
;; get rid of the scroll bar boxes
(scroll-bar-mode -1)
;; Set the tab width to 2 by default
(setq-default tab-width 2)
;; No dinging during exceptions
(setq visible-bell 1)
;; Enable keybinding to Caps Lock key
(setq w32-enable-caps-lock nil)
;; Highlight current line
(global-hl-line-mode +1)
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(load-theme 'solarized t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(global-set-key (kbd "M-x") 'helm-M-x)
; (add-to-list 'load-path "~/site-lisp/wolfram-mode-master/")
; (require wolfram-mode)
; (autoload 'wolfram-mode "wolfram-mode" nil t)
; (autoload 'run-wolfram "wolfram-mode" nil t)
; (setq wolfram-program "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Wolfram Mathematica")
; (add-to-list 'auto-mode-alist '("\\.m$" . wolfram-mode))
; (setq wolfram-path "C:\Program Files\Wolfram Research\Mathematica\10.4") ;; e.g. on Linux "~/.Mathematica/Applications"
;(overlay-put (make-overlay (line-end-position) (point-max)) 'after-string (propertize " " 'face '(:background "gray50" :foreground "black")))
(defvar-local hl-line-after-cursor nil
"Overlay used by Global-Hl-Line mode to highlight the current line.")
(defun my-hl-line-after-current-line()
(if (eq (line-end-position) (point-max))
(progn
(setq hl-line-after-cursor (make-overlay (line-end-position) (line-end-position)))
(overlay-put hl-line-after-cursor 'after-string
(propertize (make-string (- (- (window-text-width) (- (line-end-position) (line-beginning-position))) 2) (string-to-char " "))
'face hl-line-face 'cursor 1))
(move-overlay hl-line-after-cursor (line-end-position) (line-end-position))
;(overlay-put hl-line-after-cursor 'priority -50)
)))
(defun my-hl-line-after-unhighlight ()
"Deactivate the Hl-Line overlay on the current line."
(when hl-line-after-cursor
(delete-overlay hl-line-after-cursor)))
(add-hook 'pre-command-hook #'my-hl-line-after-unhighlight nil t)
(add-hook 'post-command-hook #'my-hl-line-after-current-line nil t)
更新:
以下は私の最高の試みです、stefans tipはDrewsのように間違いなく助けになりましたが、まだ弾丸ではありません。
(defun my-hl-line-after-current-line()
(unless (eq (current-buffer) (window-buffer (minibuffer-window)))
; (if (eq (car (window-margins)) nil)
; (setq linum/margin 0)
; (setq linum/margin (car (window-margins))))
(setq hl-line-after-cursor (make-overlay (line-end-position) (line-end-position)))
(let ((win (- (window-width) (if (= 0 (or (cdr fringe-mode) 1)) 1 0)))
;(let ((win (- (window-text-width) linum/margin))
(line (- (line-end-position) (line-beginning-position))))
(overlay-put hl-line-after-cursor 'after-string
(if (> win line)
(cond
((eq (line-end-position) (line-beginning-position)) ;; Sub-if-then
(goto-char (line-beginning-position))
(propertize (make-string (- win line) (string-to-char " "))
'face hl-line-face 'cursor 1)
)
((eq (line-end-position) (point-max)) ;; Sub-if-then
(propertize (make-string (- win line) (string-to-char " "))
'face hl-line-face 'cursor 1)
;(move-overlay hl-line-after-cursor (line-end-position) (line-end-position))
)
(t ;; Else
(propertize (make-string (- win line 1) (string-to-char " "))
'face hl-line-face 'cursor 1)
))
nil
)))
))
(defun my-hl-line-after-unhighlight ()
"Deactivate the Hl-Line overlay on the current line."
(when hl-line-after-cursor
(delete-overlay hl-line-after-cursor)))
(add-hook 'pre-command-hook #'my-hl-line-after-unhighlight)
(add-hook 'post-command-hook #'my-hl-line-after-current-line)
私は妻が私を詰めるために急いでいない場合、私は詳細に行くだろういくつかの奇妙な問題をポップアップを回避するために "cond"ステートメントを利用しなければならなかった。 (それを見るには、condの最初のブロックをコメントアウトし、右のマージンを見てください)。しかし、上記はほとんどの場合、機能します。
私が解決できなかったことは次のとおりです:
- テキストによる適切なスケーリング(ズームおよびズーム解除)
- ウィンドウサイズの変更後に自動的に更新されます。
その部分の助けや提案は大変ありがとう!
-update 2: "f"を打つと、その行は一瞬ひどくなり、他の文字は入力されません。
また何らかの理由で私は上記の私のusbドライブ上の私のspacemacsの設定で動作するが、私のラップトップに私のインストールされた設定ではないことに気付く(私は "cond"の最初の部分をコメントアウトする必要がある)