Duplicate TODO keywords defined in init.el - emacs

I have the following TODO keywords defined in init.el
(org-todo-keywords '((sequence "TODO(t)"
"STARTED(s)"
"WAITING(w)"
"NEXT(n)" "|"
"POSTPONED(p)"
"SOMEDAY(m)"
"DONE(d)"
"CANCELLED(c)")
(sequence "TOLEARN(l)"
"TOREVIEW(r)" "|"
"DONE(d)"
"CANCELLED(c)")))
Since I have DONE(d) and CANCELLED(C) in both sequences I see them twice when I press C-c C-t to get a menu of all the keywords.
Is is okay to have it like that or should I create a separate sequence for DONE and CANCELLED, something like this:
(org-todo-keywords '((sequence "TODO(t)"
"STARTED(s)"
"WAITING(w)"
"NEXT(n)" "|"
"POSTPONED(p)"
"SOMEDAY(m)")
(sequence "TOLEARN(l)"
"TOREVIEW(r)" "|")
(sequence "|" "DONE(d)"
"CANCELLED(c)")))
This way I think I avoid duplication.
Or do the DONE and CANCELLED need to be part of their sequence?

Related

emacs automatically highlight *E *F etc and highlight to EOL

I am trying to build my major mode for syntax highlighting log files from a certain tool flow.
and I've been using this excellent guide to get started
http://ergoemacs.org/emacs/elisp_syntax_coloring.html
but I would like to highlight "*W", "*E" and "*F"
but I cannot get that to work
here are my font-lock keywords
(setq mylog-font-lock-keywords
(let* (
;; define several category of keywords
(x-warnings '("UVM_ERROR" "UVM_FATAL" "^.*E" "F"))
(x-keywords '("UVM_INFO" "NOTE" "Note"))
(x-types '("UVM_WARNING" "*W," "xmsim"))
(x-constants '("ACTIVE" "AGENT" "ALL_SIDES" "ATTACH_BACK"))
(x-events '("at_rot_target" "at_target" "attach"))
(x-functions '("llAbs" "llAcos" "llAddToLandBanList" "llAddToLandPassList"))
;; generate regex string for each category of keywords
(x-keywords-regexp (regexp-opt x-keywords 'words))
(x-types-regexp (regexp-opt x-types 'words))
(x-constants-regexp (regexp-opt x-constants 'words))
(x-events-regexp (regexp-opt x-events 'words))
(x-functions-regexp (regexp-opt x-functions 'words))
(x-warnings-regexp (regexp-opt x-warnings 'words))
)
`(
(,x-types-regexp . font-lock-type-face)
(,x-constants-regexp . font-lock-constant-face)
(,x-events-regexp . font-lock-builtin-face)
(,x-functions-regexp . font-lock-function-name-face)
(,x-keywords-regexp . font-lock-keyword-face)
(,x-warnings-regexp . font-lock-warning-face)
;; note: order above matters, because once colored, that part won't change.
;; in general, put longer words first
)))
;;;###autoload
(define-derived-mode mylog-mode verilog-mode "log mode"
"Major mode for editing LOG FILES…"
;; code for syntax highlighting
(setq font-lock-defaults '((mylog-font-lock-keywords))))
(set-face-foreground 'font-lock-type-face "yellow")
;; add the mode to the `features' list
(provide 'mylog-mode)
as you can see I've tried a few things with out success.. any other words are highlighted correctly?
as a final touch I would like to for all occurenses of WARNING or ERROR I would like to highlight the entire line until EOL.
I have found some examples but none that show how to highlight until EOL in a major mode lisp file
This is an example (taken from my init.el). Hope it help.
(font-lock-add-keywords nil
'( ; high-light full line ending with "E" or "FATAL"
("^.*\\(E\\|FATAL\\)$" . 'font-lock-function-name-face)
; high-light full line beginning with '*E' '*F' '*W'
("^\\*[EFW]\\b.*$" . 'font-lock-comment-face)
; high-light only ending part of the lines which contain "F"
("\\b\\w*F$" . 'font-lock-function-name-face)
; high-light from "UVM" to end of line
("\\bUVM.*$" . 'font-lock-function-name-face)
; high-light only words that end with "G"
("\\b\\w*G\\b" . 'font-lock-function-name-face)
; bold things between 2 **, like **bold**
("\\*\\*.+?\\*\\*" . 'bold)))

Checking user input in Racket

I am getting an input from a user for a tex-field% in racket which would look something like this:
open button a = fwd; button b = xxx; button s = xxx; close
I have verified that it does contain open and close at beginning and end respectively. But now i need to store each of the substrings based on the semicolons to check them for semicolons at the end, among other things. For example, in the example above it should store 3 substrings in a vector/list (whichever is easier). It would be stored as:
button a = fwd;
button b = xxx;
button s = xxx;
;input is the name of the string the user enters
(define vec (apply vector (string-split input)))
(define vecaslist(vector->list vec))
(define removedopen (cdr vecaslist))
(define withoutopenandclose (reverse(cdr(reverse removedopen))))
(define stringwithoutopen (string-replace input "open " ""))
(define stringtoderivate (string-replace stringwithoutopen " close" ""))
(define tempvec (apply vector (string-split stringtoderivate ";" #:trim? #f #:repeat? #t)))
Attempted to split it by semicolons and place in a vector, but it removes the semicolons. When i do print the length of the vector it correctly shows 3 though, but i would like to keep the semicolons for now.
You can use string-split with a regular expression separator, as follows:
(string-split input #rx"(open | close)|(?<=;).")
which will output the list:
'("button a = fwd;" "button b = xxx;" "button s = xxx;")
To break down the regular expression:
(exp) matches any sub-expression "exp". Hence, (open ) matches the sub-expression "open " in input. Similarly with ( close), matching " close".
(?<=exp) does a positive look-behind, matching if "exp" matches preceding.
. matches anything, such as whitespace, characters etc.
| matches either the expression that comes before it, or after it, trying left first.

How I can change column view (org-mode, agenda) - default settings

(setq org-agenda-custom-commands
'(
("1" "TODAY" agenda "" (
(org-agenda-ndays 1)
(org-agenda-use-time-grid nil)
(org-agenda-overriding-columns-format "%TODO %7EFFORT %PRIORITY %100ITEM 100%TAGS")
(org-agenda-view-columns-initially t)))
("2" "TODO" todo "TODO"(
(org-agenda-files '("/Users/inbox.org"))
(todo "NEXT")))
("3" "DONE" todo "DONE")...
In the first filter (1 = TODAY), I have following function:
org-agenda-overriding-columns-format...
How can I add this function for all my filters (2, 3) and create this as default?
Set the variable in your .emacs (or other initialization file):
(setq org-agenda-overriding-columns-format "%TODO %7EFFORT %PRIORITY %100ITEM 100%TAGS")
BTW, org-agenda-overriding-columns-format is a variable, not a function.
You can set the column widths by customizing the org-columns-default-format variable. So:
M-x customize variable org-columns-default-format
There, you can change the number in front of each column name to the character width you want. For example, if you want the ITEM column to be 50 characters wide, change %25ITEM to %50ITEM.
And if a column doesn't have a numeric value after the percent sign, you can add one.
Hope that helps.

When do variables output properly in skeletons functions?

I'm trying to write a skeleton-function to output expressions in a loop. Out of a loop I can do,
(define-skeleton test
""
> "a")
When I evaluate this function it outputs "a" into the working buffer as desired. However, I'm having issues when inserting this into a loop. I now have,
(define-skeleton test
"A test skeleton"
(let ((i 1))
(while (< i 5)
>"a"
(setq i (1+ i)))))
I would expect this to output "aaaaa". However, instead nothing is outputted into the working buffer in this case. What is happening when I insert the loop?
The > somestring skeleton dsl does not work inside lisp forms.
You can however concatenate the string inside a loop:
(define-skeleton barbaz
""
""
(let ((s ""))
(dotimes (i 5)
(setq s (concat s "a")))
s)
)
My understanding is that code such as
> "a"
only works at the first nesting level inside a skeleton.
[EDIT] Regarding your question
What is happening when I insert the loop?
The return value of the let form (that is, the return value of the while form)is inserted. I do not know why it does not raise an error when evaluating > "a", but the return value of a while form is nil, so nothing is inserted.
I do agree that there's not much point using define-skeleton if you're going to need an (insert function within the skeleton.
This is also a rather trivial example to be using define-skeleton.
That said, they are often easier to read than a defun and useful when you want to create a function that inserts text (and optionally, takes input).
For example you may wish to have a different character repeated a set no. of times... Below, str refers to the argument supplied with the function (usually a string) and v1, v2 are the default names for local variables in a skeleton. Thus:
(define-skeleton s2 ""
nil ; don't prompt for value of 'str'
'(set 'v1 (make-string 5 (string-to-char str)))
\n v1 \n \n)
Below, calling the function leads to a newline, the string, then leaves the cursor at the position indicated by the square brackets [].
(s2 "a")
aaaaa
[]

Trying to define comments for SPSS in syntax table

I'm trying to modify spss.el to provide accurate fontification for SPSS comments. Below is a summary of how SPSS's syntax highlights and treats comments:
* = an asterisk starts commment at beginning of line
\n\n = two new lines end comments
.\n = period + newline also ends comment
/* = slash and star starts comment, and is ended with a single new line
*/ ends a comment only if on the same line as a /*
So far my syntax table reads:
(let ((spss-mode-syntax-table (make-syntax-table)))
(modify-syntax-entry ?* "<" spss-mode-syntax-table)
(modify-syntax-entry ?. ". 3" spss-mode-syntax-table)
(modify-syntax-entry ?\n "- 34" spss-mode-syntax-table)
(modify-syntax-entry ?' "\"" spss-mode-syntax-table)
(modify-syntax-entry ?\\ "# " spss-mode-syntax-table)
spss-mode-syntax-table)
This for the most part works, except that the asterisk only functions as a commment delimiter when it's at the beginning of a line. Is there a way to denote that the asterisk is a comment delimiter only at the line start?
Thank you for reading!
For the /* ... */ part, you can use
(modify-syntax-entry ?/ ". 14" st)
(modify-syntax-entry ?* ". 23" st)
(modify-syntax-entry ?\n ">" st)
But for the * ... \n\n, you need a different comment style and since it reuses the same chars * and \n as the other comment style, you can't use simple syntax-table settings to explain it to Emacs. Instead, you'll need to use a syntax-propertize-function which will place a "< b" syntax on a * at beginning of line and a "> b" syntax on the \n of \n\n. E.g.
(set (make-local-variable 'syntax-propertize-function)
(syntax-propertize-rules
("^\\(\\*\\)" (1 "< b"))
("\n\\(\n\\)" (1 "> b"))
("\\(\\.\\)\n" (1 "> b"))))