Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting not working for verilog files #1403

Closed
veripoolbot opened this issue Feb 23, 2019 · 2 comments
Closed

Syntax highlighting not working for verilog files #1403

veripoolbot opened this issue Feb 23, 2019 · 2 comments
Assignees

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Vivek Jindal
Original Redmine Issue: 1403 from https://www.veripool.org

Original Assignee: Wilson Snyder (@wsnyder)


I am running into issues with syntax highlighting using verilog-mode.el and my init.el file. The keywords are not being highlighted at all :-(
My system got recently upgraded from Redhat6 to Redhat7.

Snippet of my init.el file. All the relevant modes reside in /home/.xemacs/modes/verilog-mode.el , folding.el etc

;;{{{ GENERAL SETUP

;; ===============================
;; Customization to X-EMACS
;; ===============================
;; Settings colors for the Xemacs/emacs window
(set-face-background 'default "black") ; frame background
(set-face-foreground 'default "white") ; normal text
(set-face-background 'modeline "steelgray") ; Line at bottom of buffer
(set-face-foreground 'modeline "red") ; Line at bottom of buffer

;; ====================================
;; Controling backup files
;; ====================================

(setq make-backup-files nil);
(setq auto-save-default nil);

;; ============================
;; Load common modes
;; ============================

;; Always load perforce
(load "p4.el")

;; Always load folding mode
(load "/home/.xemacs/modes/folding.el")

;; set maximum buffer size for fontification to 2 million characters
(setq font-lock-maximum-size 2000000)

;;==================
;; Path to MODES
;;==================

;; Tell XEmacs where all the mode definition files are
(add-to-list 'load-path "/home/.xemacs/modes/")
(require 'pabbrev)

;; =============================================
;; To show line and column numbers automatically
;; =============================================
(line-number-mode 1)
(column-number-mode 1)
;; Turn on Highlighting
(font-lock-mode t)
;;(global-font-lock-mode t)
(paren-activate)
;;(pabbrev-mode 1)

;; Load pending-delete module
(load-file "/home/.xemacs/modes/pending-del.el")

;; Load RCS Verilog Header
(load-file "/home/.xemacs/modes/rcs_verilog_header.el")

;; Load Verilog Mode Only When Needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
(add-to-list 'auto-mode-alist '("\.[ds]?vh?\'" . verilog-mode))

;; Load Verilog Mode Only When Needed
(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)
(autoload 'matlab-shell "matlab" "Interactive Matlab mode." t)

;; To use spice-mode, add either the following to your `.emacs' file. This
;; assumes that you will use the .sp, .cir, .ckt, .mod, ... extensions for
;; your spice source decks and output files:
(autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)

;; Set up Customization
'(turn-on-auto-delete-selection)

;; To ignore comments from messing up indentation
(setq parse-sexp-ignore-comments 1);

;; font-lock-constant-face does not appear to come with Xemacs by default.
(unless (boundp 'font-lock-constant-face)
(copy-face 'font-lock-keyword-face 'font-lock-constant-face))

;; =====================================================
;; To set up xemacs to edit c/perl/verilog automatically
;; =====================================================
(setq auto-mode-alist (cons '("\.h$" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.c$" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.cpp$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.cc$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.tcl$" . tcl-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.pl$" . perl-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.v$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.sv$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.psl$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.prop$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.def$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.scr$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.pkg$" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.vhd$" . vhdl-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.m\'" . matlab-mode) auto-mode-alist))
(setq auto-mode-alist (append (list (cons "\.sp$" 'spice-mode) (cons "\.net$" 'spice-mode)) auto-mode-alist))
;; =====================================================

;; Exuberant TAGS setup
(setq path-to-ctags "/usr/bin/ctags")
(setq tags-build-completion-table t)

;;}}}

;;{{{ KEY BINDINGS
;; =====================
;; Experimental commands
;; =====================

;; To toggle hiding
(defalias 'toggle-hiding
(read-kbd-macro "C-c @ C-c"))

;; Function keys
(global-set-key 'f1 goto-line) (global-set-key 'f2 undo)
(global-set-key 'f3 query-replace-regexp) (global-set-key 'f4 shell-command)
(global-set-key 'f5 revert-all-buffers) (global-set-key 'f6 comment-region)
(global-set-key 'f7 kill-rectangle) ;; To uncomment commented region (global-set-key 'f8 kill-buffer)
(global-set-key 'f9 buffer-menu) ;; List all open buffers (global-set-key 'f10 setnu-mode) ;; Selectively save all active buffers (prompts)
(global-set-key 'f11 switch-to-buffer) (global-set-key 'f12 string-rectangle) ;;
(global-set-key (kbd "") 'delete-char)
(global-set-key (kbd "") 'delete-char)
(global-set-key "\C-cb" `list-buffers)

;; Keyboard shortcuts for folding mode
(global-set-key (kbd "C-f1") 'folding-open-buffer)
(global-set-key (kbd "C-f2") 'folding-whole-buffer)
(global-set-key (kbd "C-f3") 'folding-toggle-show-hide)

;; Keyboard shortcuts for TAGs
(global-set-key (kbd "C-f5") 'create-tags)
(global-set-key (kbd "C-f6") 'find-tag)
(global-set-key (kbd "C-f7") 'pop-tag-mark)
(global-set-key (kbd "C-f9") 'align-repeat)
(global-set-key (kbd "C-f10") 'checkout-buffer-and-reload)
(global-set-key (kbd "C-f11") 'load-library)

;;=========
;; No Tabs
;;=========

(setq-default indent-tabs-mode nil) ;tabs as spaces
(setq-default tab-width 4)
(setq tab-stop-list '(4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80))

;; Set scrolling to one line instead of half a page
(setq scroll-step 1)
; Set Tab spacing
;(setq-default tab-width 4)

(setq auto-compression-mode t)

; gets rid of pesky warning message for read only files
(setq pabbrev-read-only-error nil)
;;}}}

;;{{{ MINOR MODES

;; =================
;; FOLDING MODE
;; =================
;; Define folding for cperl mode
(add-hook 'cperl-mode-hook 'folding-mode)
(folding-add-to-marks-list 'cperl-mode "## {{{" "## }}}" nil t)

;; Define folding for emacs lisp mode
(add-hook 'emacs-lisp-mode-hook 'folding-mode)
(folding-add-to-marks-list 'emacs-lisp-mode ";; {{{" ";; }}}" nil t)

;; Define folding for matlab mode
(add-hook 'matlab-mode-hook 'folding-mode)
(folding-add-to-marks-list 'matlab-mode "%% {{{" "%% }}}" nil t)

;; Define folding for verilog mode
(add-hook 'verilog-mode-hook 'folding-mode)
(folding-add-to-marks-list 'verilog-mode "// {{{" "// }}}" nil t)

;; PABBREV MODE (Autocomplete)
(add-hook 'verilog-mode-hook 'pabbrev-mode)

;; AUTOCOMPLETE MODE
;(add-to-list 'load-path "/.xemacs/packages/auto-complete/")
;(require 'auto-complete-config)
;(add-to-list 'ac-dictionary-directories "
/.xemacs/packages/auto-complete//ac-dict")
;(ac-config-default)
(add-to-list 'load-path "/home/vjindal/.xemacs/packages/")

(defvar hs-special-modes-alist
(mapcar 'purecopy
'((verilog-mode "{{{" "}}}" "/[*/]" nil nil))))

(add-hook 'verilog-mode-hook 'hs-minor-mode)

;; Define Insert Time Function
(defun insert-time ()
(interactive)
(insert (format-time-string "%b %d, %Y, %R %Z")))
;; Define Insert Time Function
(defun insert-time ()
(interactive)
(insert (format-time-string "%b %d, %Y, %R %Z")))

;; Any files in verilog mode should have their keywords colorized
;;(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))

;; Set Verilog Mode User Parameters
(custom-set-variables
'(verilog-indent-level 0)
'(column-number-mode t)
'(verilog-indent-level-module 0)
'(line-number-mode t)
'(verilog-indent-level-declaration 0))

;; Replace tabs with spaces or Untabify
;;(add-hook 'verilog-mode-hook '(lambda () (add-hook 'local-write-file-hooks
;; (lambda() (untabify (point-min) (point-max))))))

;; Load Matlab Module
(defun my-matlab-mode-hook ()
(setq matlab-indent-function t) ; if you want function bodies indented
(setq fill-column 76) ; where auto-fill should wrap
;(matlab-mode-hilit)
(turn-on-auto-fill))
(setq matlab-mode-hook 'my-matlab-mode-hook)
(defun my-matlab-shell-mode-hook ()
'())
(setq matlab-mode-hook 'my-matlab-mode-hook)

;; Function to create a TAGS file
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(shell-command
(format "%s --exclude="vmtag*" -f %s/TAGS -e -R --languages=verilog --langmap=verilog:.v.vh.sv.svh %s" path-to-ctags dir-name (directory-file-name dir-name)))
;(add-to-tag-completion-table-exuberant-ctags)
(visit-tags-table (directory-file-name dir-name))
)

;; align characters at a particular column (useful for indenting)
(defun align-repeat (start end regexp)
"Repeat alignment with respect to
the given regular expression."
(interactive "r\nsAlign regexp: ")
(align-regexp start end
(concat "\(\s-*\)" regexp) 1 1 t))

;; Function to revert all buffers visiting a modified file
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files."
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (and (buffer-file-name) (not (buffer-modified-p)))
(revert-buffer t t t) )))
(message "Refreshed open files.") )

;; Function to RCM checkout current buffer and reload it for edit
(defun checkout-buffer-and-reload ()
"Checks out buffer and reloads it for edit."
(interactive)
(shell-command (concat "rcm co " (shell-quote-argument (buffer-file-name))))
(revert-buffer t t t)
(delete-other-windows)
(message "Checked out %s" (buffer-file-name)) )

;;=======================================
;; scroll on mouse wheel
;;=======================================

;; scroll on wheel of mouses
(define-key global-map 'button4
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 5)
(select-window curwin)
)))
(define-key global-map [(shift button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 1)
(select-window curwin)
)))
(define-key global-map [(control button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down)
(select-window curwin)
)))

(define-key global-map 'button5
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 5)
(select-window curwin)
)))
(define-key global-map [(shift button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 1)
(select-window curwin)
)))
(define-key global-map [(control button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up)
(select-window curwin)
)))
;;}}}

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Vivek Jindal
Original Date: 2019-02-23T23:41:51Z


Never mind figured it out. Kindly ignore.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-02-26T22:25:59Z


Glad you solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants