Strange Logbook spacing when prettifying todo keywords - emacs

I am prettifying org-mode todo keywords by defining respective symbols. Now, I tried to enable logging of todo state changes in the logbook, but encounter issues regarding the spacing.
Please note the following setup:
Org-mode todo sequence:
(setq org-todo-keywords
(sequence "NEW(n!)" "TODO(t!)" "PROGRESS(p!)" "|" "DONE(d!)" "CANCELED(c!)"))
Prettify-helper:
(add-hook 'org-mode-hook (lambda ()
"Beautify Org Checkbox Symbol"
(push '("NEW" . "⚠") prettify-symbols-alist)
(push '("TODO" . "☛") prettify-symbols-alist)
(push '("PROGRESS" . "⚙") prettify-symbols-alist)
(push '("DONE" . "✔") prettify-symbols-alist)
(push '("CANCELED" . "✘") prettify-symbols-alist)
(prettify-symbols-mode)))
org-log-note-headings:
Heading when changing todo state (todo sequence only)
String: State %-12s from %-12S %t
This yields the following logbook entry:
:LOGBOOK:
- State "TODO" from "NEW" [2022-06-28 Di 15:28]
- State "NEW" from "TODO" [2022-06-28 Di 15:28]
- State "TODO" from "PROGRESS" [2022-06-28 Di 15:28]
- State "PROGRESS" from "DONE" [2022-06-28 Di 15:28]
- State "DONE" from "CANCELED" [2022-06-28 Di 15:28]
:END:
Note the sloppy spacing of the date. This does not occur if I remove prettifying of the symbols, i.e. it appears that the spacing of the second todo info (%S) is determined based on the prettified symbol instead of the true length of the todo keywords.
Can someone help me, overcome this in order to obtain the following logbook:
:LOGBOOK:
- State "TODO" from "NEW" [2022-06-28 Di 15:28]
- State "NEW" from "TODO" [2022-06-28 Di 15:28]
- State "TODO" from "PROGRESS" [2022-06-28 Di 15:28]
- State "PROGRESS" from "DONE" [2022-06-28 Di 15:28]
- State "DONE" from "CANCELED" [2022-06-28 Di 15:28]
:END:

Related

Duplicate TODO keywords defined in init.el

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?

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

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.

org--agenda-prefix-format %? does not work

Currently, I have my global TODO list shown as follows thanks to erikstokes:
(org-agenda-prefix-format " %i %?-12(concat \"[ \"(org-format-outline-path (list (nth 1 (org-get-outline-path)))) \" ]\") ")))
which outputs:
for org layout:
However, as you can see, for Task A, even though there is nothing in the project, it still shows up on the list.
describe-variable for org-agenda-prefix-format says :
If the first character after `%' is a question mark, the entire field
will only be included if the corresponding value applies to the current
entry. This is useful for fields which should have fixed width when
present, but zero width when absent.
So I feel like by using %?, [ ] shouldn't be there for Task A, yet it still shows up.
The problem is that the field is never empty: it will always contain at least the left and right square brackets plus the white space to bring it to a width of 12.
The solution is to write a function that returns either an empty string or the bracketed project and use that in the format:
(defun foo ()
(let ((x (nth 1 (org-get-outline-path))))
(if x
(concat "[ " (org-format-outline-path (list x)) " ]")
"")))
(setq org-agenda-prefix-format " %i %?-12(foo) "

switch between printing configurations in emacs

The default printing in emacs is to print one page per paper with some margins.
I have this function that changes the margins and sets printing to two pages per paper "most numbers are to maximize printing space:
(defun ps-two-per-page ()
(interactive)
(require 'ps-print)
(setq ps-n-up-printing 2
ps-n-up-border-p nil
ps-paper-type 'letter
ps-font-size (quote (8 . 11))
ps-top-margin -20
ps-bottom-margin -35
ps-left-margin 18
ps-right-margin 18
ps-n-up-margin 1
ps-inter-column 1
)
'ps-two-per-page)
Once the function executes I will no longer able to go back to the default printing configuration.
How is it possible for me to go back to print using default configuration "as if I did not execute the above command"?
Also, is there way to bind the printing commands in emacs under the "file" drop down menu.
Meaning, I would like to bind "Postscript Print Buffer" to be print using the default configuration, and "Postscript Print Buffer (B+W)" to follow the configuration I have in the above command ps-two-per-page.
WRT to first question: while ignoring the details of ps-print, in these cases two strategies are to adopt
1) set variables behind a let
2) store old values with a prefix old-... and reset afterward.
Here a draft of the second way:
(defun ps-two-per-page ()
(interactive)
(require 'ps-print)
(setq old-ps-n-up-printing ps-n-up-printing
old-ps-n-up-border-p ps-n-up-border-p
old-ps-paper-type ps-paper-type
old-ps-font-size ps-font-size
old-ps-top-margin ps-top-margin
old-ps-bottom-margin ps-bottom-margin
old-ps-left-margin ps-left-margin
old-ps-right-margin ps-right-margin
old-ps-n-up-margin ps-n-up-margin
old-ps-inter-column ps-inter-column
ps-n-up-printing 2
ps-n-up-border-p nil
ps-paper-type 'letter
ps-font-size (quote (8 . 11))
ps-top-margin -20
ps-bottom-margin -35
ps-left-margin 18
ps-right-margin 18
ps-n-up-margin 1
ps-inter-column 1))
(defun ps-restore-default ()
"Get old values back"
(interactive)
(require 'ps-print)
(setq ps-n-up-printing old-ps-n-up-printing
ps-n-up-border-p old-ps-n-up-border-p
ps-paper-type old-ps-paper-type
ps-font-size old-ps-font-size
ps-top-margin old-ps-top-margin
ps-bottom-margin old-ps-bottom-margin
ps-left-margin old-ps-left-margin
ps-right-margin old-ps-right-margin
ps-n-up-margin old-ps-n-up-margin
ps-inter-column old-ps-inter-column))