why does syntax highlighting disable when I use web-mode in emacs? - emacs

This is my init.el
(require 'web-mode)
(setq web-mode-tag-auto-close-style 1)
(setq web-mode-enable-auto-closing t)
What should I do?

For example
'(web-mode-doctype-face
((t (:foreground "#4A8ACA"))))
'(web-mode-html-tag-face
((t (:foreground "#4A8ACA"))))

Related

Emacs 26.3 scrollbar refuses to move up if not moved up immediately

On Fedora Release 31. Using Xming on Windows 7 as X server. EDIT: also Emacs 24.3 running on RHEL7 with MobaXterm 12.2 4204, whether in -Q mode or not
The scrollbar I'm seeing is a medium-dark rectangle (the scrollbar "elevator") with rounded left-hand corners and square right-hand corners, in a light-gray vertical area (the scrollbar "track"). When I mouse over the rectangle it switches to dark gray.
When I click it, it turns blue. After about 1/2 second, if not moved, it narrows about 2 pixels on the right [EDIT: on the 24.3/RHEL7/MobaXterm setup, narrows on both sides], and refuses to move. Moving the mouse will sometimes get one scroll of the window contents, and sometimes not.
If I click it and move it slightly in that 1/2 second, it will move, and continue to be movable even if I hold still for a while. But I have to move it substantially (at least half its height, it seems, in a 2000 line file) or it will then freeze at the 1/2 second mark.
Here's my current .emacs file:
(defun switch-to-next-buffer-frank ()
(interactive)
(switch-to-buffer (other-buffer)))
(defun switch-to-prev-window ()
(interactive)
(other-window -1))
(defun scroll-one-line-up (&optional arg)
"Scroll the selected window up (forward in the text) one line (or N lines)."
(interactive "p")
(scroll-up (or arg 1)))
(defun scroll-one-line-down (&optional arg)
"Scroll the selected window down (backward in the text) one line (or N)."
(interactive "p")
(scroll-down (or arg 1)))
(global-set-key [(control ?z)] 'scroll-one-line-up)
(global-set-key [(meta ?z)] 'scroll-one-line-down)
(global-set-key [(meta ?g)] 'goto-line)
(global-set-key [(control ?x)(k)] 'kill-this-buffer)
(global-set-key [(control meta ?l)] 'switch-to-next-buffer)
(global-set-key [(control shift meta ?l)] 'switch-to-prev-buffer)
(global-set-key [(control tab)] 'other-window)
(global-set-key [(control shift iso-lefttab)] 'switch-to-prev-window)
(modify-syntax-entry ?_ "w")
(setq scroll-bar-mode 'left)
(setq scroll-bar-adjust-thumb-portion nil)
(setq gutter-buffers-tab-visible-p nil)
(setq inhibit-startup-screen t)
(setq mouse-yank-at-point t)
(setq inhibit-startup-buffer-menu t)
(tool-bar-mode -1)
(delete-selection-mode 1)
;(setq inhibit-splash-screen t)
;(setq inhibit-startup-message t)
;(setq initial-scratch-message nil)
;(delete-selection-mode 1)
;
;(defun ask-user-about-supersession-threat (fn)
; "blatantly ignore files that changed on disk"
; )
(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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["#3F3F3F" "#CC9393" "#7F9F7F" "#F0DFAF" "#8CD0D3" "#DC8CC3" "#93E0E3" "#DCDCCC"])
'(background-color "#000000")
'(background-mode dark)
'(company-quickhelp-color-background "#4F4F4F")
'(company-quickhelp-color-foreground "#DCDCCC")
'(cursor-color "#ffffff")
'(custom-enabled-themes (quote (manoj-dark)))
'(custom-safe-themes
(quote
("54f2d1fcc9bcadedd50398697618f7c34aceb9966a6cbaa99829eb64c0c1f3ca" "4138944fbed88c047c9973f68908b36b4153646a045648a22083bd622d1e636d" "8885761700542f5d0ea63436874bf3f9e279211707d4b1ca9ed6f53522f21934" "59e82a683db7129c0142b4b5a35dbbeaf8e01a4b81588f8c163bd255b76f4d21" default)))
'(fci-rule-color "#383838")
'(font-use-system-font t)
'(foreground-color "#00ff00")
'(gutter-buffers-tab-visible-p nil t)
'(indent-tabs-mode nil)
'(nrepl-message-colors
(quote
("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3")))
'(pdf-view-midnight-colors (quote ("#DCDCCC" . "#383838")))
'(query-user-mail-address nil)
'(tool-bar-mode nil)
'(user-mail-address "fsheeran#gmail.com")
'(vc-annotate-background "#2B2B2B")
'(vc-annotate-color-map
(quote
((20 . "#BC8383")
(40 . "#CC9393")
(60 . "#DFAF8F")
(80 . "#D0BF8F")
(100 . "#E0CF9F")
(120 . "#F0DFAF")
(140 . "#5F7F5F")
(160 . "#7F9F7F")
(180 . "#8FB28F")
(200 . "#9FC59F")
(220 . "#AFD8AF")
(240 . "#BFEBBF")
(260 . "#93E0E3")
(280 . "#6CA0A3")
(300 . "#7CB8BB")
(320 . "#8CD0D3")
(340 . "#94BFF3")
(360 . "#DC8CC3"))))
'(vc-annotate-very-old-color "#DC8CC3"))
(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.
'(default ((t (:foreground "#00ff00" :background "#000000" :size "10pt" :family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 144 :width normal))))
'(font-lock-builtin-face ((t (:foreground "#00ccff"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#ffff00" :slant normal))))
'(font-lock-comment-face ((t (:foreground "#ffff00" :slant normal))))
'(font-lock-constant-face ((t (:foreground "#00ff99" :weight normal))))
'(font-lock-function-name-face ((t (:foreground "#00ff00" :weight normal :height 1.0))))
'(font-lock-preprocessor-face ((t (:foreground "#ff4040"))))
'(font-lock-string-face ((t (:foreground "#00ffee"))))
'(font-lock-type-face ((t (:foreground "#33ccff"))))
'(font-lock-variable-name-face ((t (:foreground "#66ff00"))))
'(italic ((t nil)))
'(mode-line ((t (:background "#445555" :foreground "#ffffff" :box (:line-width 2 :color "#445555") :height 1.0))))
'(mode-line-buffer-id ((t (:background "#445555" :foreground "#55ff55" :weight normal :height 1.0))))
'(mode-line-emphasis ((t (:weight normal))))
'(mode-line-highlight ((t (:box (:line-width 2 :color "#445555")))))
'(mode-line-inactive ((t (:background "#445555" :foreground "#ffffff" :box (:line-width 2 :color "#445555") :weight normal :height 1.0))))
'(scroll-bar ((t (:background "#334444" :foreground "#ddffff")))))
Here's a screenshot: of emacs -Q 24.3/RHEL7/MobaXterm:
Then here is the same window after I've held the top scrollbar about 1 second without moving after clicking down:

How to color entries in emacs's ibuffer by buffer type?

How can I color entries in ibuffer accoding to the buffer type ?
Based on which mode the buffer is - for example python mode is blue, lisp mode is yellow etc ...
Is this possible ?
Building on the comment from #lawlist, here's some sample code you could use and tweak to your liking:
(setq ibuffer-fontification-alist
'((1 (eq major-mode 'c++-mode) yellow-face)
(1 (eq major-mode 'fundamental-mode) green-face)
(1 (member major-mode '(shell-mode sh-mode)) purple-face)
(1 (eq major-mode 'tcl-mode) brown-face)))
(defface yellow-face '((t :foreground "yellow")) "")
(defface green-face '((t :foreground "green")) "")
(defface purple-face '((t :foreground "black")) "")
(defface brown-face '((t :foreground "brown")) "")
Obviously you can use existing faces, or create new ones (like in this example). See the manual for faces for more information.

emacs 24.3 ignoring foreground/background color with color-theme?

I've been using color-theme for quite awhile to set colors in my .emacs:
(defun custom-theme ()
(interactive)
(color-theme-install
'(custom-theme
((background-color . "black")
(background-mode . dark)
(border-color . "#0d1b2b")
(cursor-color . "#fce94f")
(foreground-color . "#dddddd")
(mouse-color . "black"))
(isearch ((t (:inverse-video t :underline t ))))
(lazy-highlight ((t (:inverse-video t :underline t ))))
(hl-line ((t (:background "gray13" ))))
(fringe ((t (:background "#0d1b2b" ))))
(mode-line ((t (:foreground "#bbbbbb" :background "#353e4b"))))
(region ((t (:background "gray13" ))))
(font-lock-builtin-face ((t (:foreground "#9c56dc" ))))
(font-lock-comment-face ((t (:foreground "#187093" ))))
(font-lock-function-name-face ((t (:foreground "#edd400" :underline t ))))
(font-lock-keyword-face ((t (:foreground "#b47113" ))))
(font-lock-string-face ((t (:foreground "#e65351" ))))
(font-lock-type-face ((t (:foreground "#3257d2" ))))
(font-lock-constant-face ((t (:foreground "#cc1e1e" ))))
(font-lock-variable-name-face ((t (:foreground "#cccccc" ))))
(minibuffer-prompt ((t (:foreground "#729fcf" :bold t ))))
(font-lock-warning-face ((t (:foreground "#BB0000" :inverse-video t :underline "#bbbbbb" ))))
)
)
)
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(custom-theme)))
However, in 24.3 now, for some reason when I open emacs in the terminal (emacs -nw), it's ignoring the background and foreground colors, so I get a white editor background regardless. What's more, emacs is ignoring the -bg and -fg flags passed on the command line.
I've found that I can sort of force the colors on frame setup with something like this:
(defun on-after-init ()
(unless (display-graphic-p (selected-frame))
(progn
(set-face-background 'default "black" (selected-frame))
(set-face-foreground 'default "#dddddd" (selected-frame)))))
(add-hook 'window-setup-hook 'on-after-init)
But this feels like a hack, I'd like to understand why emacs isn't interpreting my color theme correctly. My TERM is set to xterm-256color, though setting back to plain xterm doesn't seem to affect anything.

only highlight "*", not the entire heading line in org-mode, emacs

How can I only highlight the * star, not the entire heading line, to keep texts in same color? In the great emacs org-mode
thanks guys
excample (replace * by #, for cann't bold * in stack-overflow)
(not below)
# heading text
this is text body
(but below)
# heading text
this is text body
Updated Answer
See the variable org-level-color-stars-only, which contains a doc-string that states: "Non-nil means fontify only the stars in each headline. When nil, the entire headline is fontified. Changing it requires restart of `font-lock-mode' to become effective also in regions already fontified."
USAGE:  (setq org-level-color-stars-only t)
Previous Answer
You can remove or add stars as you see fit -- this example uses two (2) stars together. If you do just one star, then that would also affect two (2) and three (3) stars together. Maybe one of our forum local regexp experts could please give us the code for one star (but not more than one star) :)
(defvar bumble-bee (make-face 'bumble-bee))
(set-face-attribute 'bumble-bee nil :background "black" :foreground "yellow")
(font-lock-add-keywords 'org-mode (list
(list (concat "\\*\\*")
'(0 bumble-bee t))
))
These control the title of tasks -- you could set them all the same or make them different. Anything you don't want, just set to nil or set to the same color as whatever your regular font is.
(custom-set-faces
'(org-level-1 ((t (:foreground "orange" :bold t))))
'(org-level-2 ((t (:foreground "black" :bold t))))
'(org-level-3 ((t (:foreground "pink" :bold t))))
'(org-level-4 ((t (:foreground "cyan" :bold t))))
)
The other components of the first line are usually: org-tag; org-tag-faces; org-todo-keyword-faces; org-priority-faces; and org-warning:
(setq org-todo-keyword-faces '(
("Active" . (:foreground "red"))
("Next Action" . (:foreground "ForestGreen"))
("Reference" . (:foreground "purple"))
("Someday" . (:foreground "gray65"))
("None" . (:foreground "green"))
("Delegated" . (:foreground "cyan")) ))
(setq org-tag-faces '(
("TODO" . org-warning)
))
(setq org-priority-faces '(
(?A . (:foreground "firebrick" :weight bold))
(?B . (:foreground "orange"))
(?C . (:foreground "green"))
(?D . (:foreground "purple"))
(?E . (:foreground "blue")) ))
(custom-set-faces
'(org-tag ((t (:background "gray97" :foreground "gray50"
:box (:line-width 1 :color "black") :weight regular))))
'(org-warning ((t (:foreground "black"))))
)

emacs color-theme problem

I created my own color theme using this website. I've added a new .el file to my ./site-lisp/color-theme/themes directory with the following code:
(defun your-config-name-here ()
(interactive)
(color-theme-install
'(your-config-name-here
((background-color . "#ffffff")
(background-mode . light)
(border-color . "#000000")
(cursor-color . "#333333")
(foreground-color . "#000000")
(mouse-color . "black"))
(fringe ((t (:background "#000000"))))
(mode-line ((t (:foreground "#000000" :background "#666666"))))
(region ((t (:background "#999999"))))
(font-lock-builtin-face ((t (:foreground "#000000"))))
(font-lock-comment-face ((t (:foreground "#000000"))))
(font-lock-function-name-face ((t (:foreground "#000000"))))
(font-lock-keyword-face ((t (:foreground "#000000"))))
(font-lock-string-face ((t (:foreground "#000000"))))
(font-lock-type-face ((t (:foreground"#000000"))))
(font-lock-variable-name-face ((t (:foreground "#000000"))))
(minibuffer-prompt ((t (:foreground "#7299ff" :bold t))))
(font-lock-warning-face ((t (:foreground "Red" :bold t))))
)))
(provide 'your-config-name-here)
And this in my .emacs file:
(add-to-list 'load-path "~/../site-lisp/color-theme/")
(add-to-list 'load-path "~/../site-lisp/color-theme/themes")
(require 'color-theme)
(require 'your-config-name-here)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(your-config-name-here)))
The problem is that I've noticed that when I change settings in your-config-name-here.el and exit emacs and reload it, that the changes don't take affect until I do this:
M-x load-file ~/../site-lisp/color-theme/themes/your-config-name-here.el
M-x your-config-name-here
It 'feels' like color-theme is caching the settings somewhere and not reloading then on start-up. What am I missing?
In your code, you have a call to 'color-theme-initialize, which doesn't exist as a function in the package color-theme.el.
(eval-after-load "color-theme"
'(progn
;; remove this call (color-theme-initialize)
(your-config-name-here)))
And then your code works.