all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Eval-buffer works, init does not hl-line fix
@ 2016-06-30 22:20 JOE Staursky
  2016-07-01  3:50 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: JOE Staursky @ 2016-06-30 22:20 UTC (permalink / raw)
  To: help-gnu-emacs

I have written the following bit of emacs lisp that allows hl-line to
extend past end of buffer to the rest of the line.

Problem is, this only works if I use (eval-buffer) after start-up and not
when I have it saved inside my .emacs file.

However,

I doubt that could cause this sort of difficulty.

Basically I am trying to make the current highlight line act more like
contemporary editors.

what could be interfering in the init file but not while in buffer?


    (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)

my init file
(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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-01  3:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-30 22:20 Eval-buffer works, init does not hl-line fix JOE Staursky
2016-07-01  3:50 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.