From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: JOE Staursky Newsgroups: gmane.emacs.help Subject: Eval-buffer works, init does not hl-line fix Date: Thu, 30 Jun 2016 22:20:29 +0000 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1467344574 2683 80.91.229.3 (1 Jul 2016 03:42:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Jul 2016 03:42:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 01 05:42:47 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bIpLq-0004nF-Tm for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Jul 2016 05:42:47 +0200 Original-Received: from localhost ([::1]:53542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIpLq-00069A-8x for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 23:42:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIkKA-0005ML-OB for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 18:20:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIkK7-0003RU-M8 for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 18:20:41 -0400 Original-Received: from mail-it0-x229.google.com ([2607:f8b0:4001:c0b::229]:36386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIkK7-0003RP-Er for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 18:20:39 -0400 Original-Received: by mail-it0-x229.google.com with SMTP id a5so3617796ita.1 for ; Thu, 30 Jun 2016 15:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=6vX+mz69n/35HSarharrkW9u5BlzdyAftFO95+xYcQE=; b=hGwyaQJOp2oWdqS/H37bz1pEzhCntSK156TyvjHIXKYNQIfVEYvONtRGFf8Uz699NJ ezYA1jho7TbRxF88IgpDEQuRTdEWBBjWQUpNjQG0pCnGicANlV3LSpAS60+f1QQDEB7D J9poWZUh2iR2x06+IFi/SvYBAKIBaRh9SRQ96XBVmmfYQ2rfnKR5Lvrj4M3tPKa/4m+5 C6bvipQ+7dltfmfGCKXTxmHjjaJ+gnLuyms+Majzs7TrmRzeuWqKOikAnuWGE58C8cZ2 h9z7gczynqyHCdY4/BhqZKJw5x43+Zw/jZX/kbiR6AZQaFizZ1HAwtnEzu9KYayS3FUJ j1cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=6vX+mz69n/35HSarharrkW9u5BlzdyAftFO95+xYcQE=; b=ScySxYvcKSRPHOsUYn5Hklrs1PyRAJRh8XuT9/QP1tdBCcJtC3Bkyr1nExR9C7LCcr lQIWFxXcVH44zpH5bvBXbbZ08TFYO6zd95zWZYgPhfLLz5uindQUnRWEJQ7jJphYFGcg v8EJuJBeFQrYw5ia8sYzSd0+cf+I2jH+HxRYBPdoe8Xm1XxgLvgnuKQbpJMaiIQDUxRA QiYz5iru3Gr/LOyHWbZjvPA2Ntv5x7sOkpI3wOpw3Mzha8wGwu9lBKP9r7FTxgLMS1Me 8ca8Qr1qJlRLahAoHOMT1paG1nFWJqNT0XvTfJ5xFG5ZnwPpQGsyiIN62n1IxZQLFFO7 Brbg== X-Gm-Message-State: ALyK8tIkXufsGHrNWao+gSrW0NBt5KRXx4vYi55yYPyb5OwMwC5a8oW74RrLu+O4lu3EHfWlHp1LEZMSVj9aig== X-Received: by 10.36.57.199 with SMTP id l190mr30197937ita.5.1467325238378; Thu, 30 Jun 2016 15:20:38 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c0b::229 X-Mailman-Approved-At: Thu, 30 Jun 2016 23:42:08 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110678 Archived-At: 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)