Getting custom org-agenda with show entry text - emacs

I've tried to build custom agenda that show entry text but can't figure out.
Here is the example:
(setq org-agenda-custom-commands
'(
("w" "Work"
((agenda ""
(
(org-agenda-files '("~/Dropbox/org/work.org")))
)
(alltodo ""
((org-agenda-overriding-header "Work todo items") (org-super-agenda-groups
'((:auto-category t)))
(org-agenda-files '("~/Dropbox/org/work.org")))
)
(agenda ""
((org-agenda-overriding-header "Work journal")
(org-super-agenda-groups
'(
(:name "Work"
:tag "work")
))
(org-agenda-span 7)
(org-agenda-entry-text-mode 't)
(org-agenda-include-inactive-timestamps 't)
;; it doesn't work
(org-agenda-entry-text-mode 't)
(org-agenda-time-grid 'nil)
(org-agenda-files '("~/Dropbox/org/journal.org")))
)
)
)
))
So I've tried to configure "Work journal" entry but it still doesn't show entry text for inactive-timestamps although I able to manually execute (org-agenda-entry-text-mode) command in agenda view and it displays me exactly what I want.

Related

Org mode: Problems with folding (no matching item found on current line)

I'm having a weird problem with Emacs (doom-emacs) on macOS (brew cask emacs-mac-spacemacs-icon): I sporadically cannot fold a heading. I can unfold it, then its children are shown, however, when I try to fold it I get the message "No matching item found on the current line". Sometimes it works again after changing to another application and tabbing back, the the message line shows "FOLDED" and "CHILDREN" when I press the Tab key.
It also works in some org files, but not in others. I don't know what's differen between them.
I just realized that when I have an inactive timestamp as a heading, pressing tab once shows the children but pressing it again just jumps between the brackets...
Here is my configuration:
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
(setq doom-font (font-spec :family "Meslo LG M for Powerline"
:size 12))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-gruvbox)
;; Enable visual line mode per default for text files
(add-hook! 'text-mode-hook 'turn-on-visual-line-mode)
;; Enable org-autolist
(add-hook 'org-mode-hook (lambda () (org-autolist-mode)))
;; Org mode configuration
(setq org-directory "~/org")
(setq org-default-clock-file (concat org-directory "/clock.org"))
(after! org
(setq org-agenda-files (list org-directory))
(setq org-default-notes-file (concat org-directory "/inbox.org"))
(setq org-task-file (concat org-directory "/tasks.org"))
(setq org-log-into-drawer t)
(setq org-log-done nil)
(setq org-image-actual-width (/ (display-pixel-width) 3))
(setq org-todo-keywords
'((sequence "TODO(t)" "IN-PROGRESS(i!)" "WAITING(#w)" "|"
"DONE(d!)" "CANCELED(#c)")))
(setq org-todo-keyword-faces
'(
("TODO" . (:foreground "#fb4933" :weight bold))
("IN-PROGRESS" . (:foreground "#fabd2f" :weight bold))
("WAITING" . (:foreground "#fe8019" :weight bold))
("DONE" . (:foreground "#8ec07c" :weight bold))
("CANCELED" . (:foreground "#83a598" :weight bold))
)
)
(setq org-capture-templates
`(("r" "Weekly report" entry (file+headline org-default-clock-file "Clock")
,(concat "** Woche %<%V>\n"
"*** Gesamt\n"
"#+BEGIN: clocktable :scope agenda :maxlevel 20 :block 2020-W%<%V> :step week :stepskip0 t\n"
"#+END:\n"
"*** Tage\n"
"#+BEGIN: clocktable :scope agenda :maxlevel 20 :block 2020-W%<%V> :step day :stepskip0 t\n"
"#+END:"
)
)))
(setq org-startup-indented t)
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(setq org-duration-format (quote h:mm))
(setq org-refile-targets '((org-agenda-files :maxlevel . 10)))
(setq org-goto-interface 'outline-path-completion)
(defvar org-created-property-name "CREATED"
"The name of the org-mode property that stores the creation date of the entry")
(defun org-set-created-property (&optional active NAME)
"Set a property on the entry giving the creation time.
By default the property is called CREATED. If given the `NAME'
argument will be used instead. If the property already exists, it
will not be modified."
(interactive)
(let* ((created (or NAME org-created-property-name))
(fmt (if active "<%s>" "[%s]"))
(now (format fmt (format-time-string "%Y-%m-%d %a %H:%M"))))
(unless (org-entry-get (point) created nil)
(org-set-property created now))))
;; Key mappings
(map! :leader
(:prefix ("o" . "org")
:desc "Goto" "g" 'org-goto
:desc "Insert inactive timestamp" "!" 'org-time-stamp-inactive
:desc "Update dynamic block" "u" 'org-dblock-update
:desc "Todo list" "t" 'org-todo-list
:desc "Agenda" "a" 'org-agenda
:desc "Tag search" "m" 'org-tags-view
:desc "Search org headlines" "h" #'+default/org-notes-headlines
:desc "Search org files" "s" #'+default/org-notes-search
:desc "Refile" "r" 'org-refile
:desc "Browse notes" "f" #'+default/browse-notes
:desc "Search notes for symbol" "." #'+default/search-notes-for-symbol-at-point
:desc "Org capture" "n" #'org-capture
(:prefix ("c" . "clock")
:desc "Clock in" "i" 'org-clock-in
:desc "Clock out" "o" 'org-clock-out
:desc "Jump to last clock" "l" (lambda () (interactive) (setq current-prefix-arg '(4)) (org-clock-goto))
:desc "Jump to active clock" "j" 'org-clock-goto)
(:prefix ("p" . "properties")
:desc "Set CREATED property" "c" 'org-set-created-property)
))
)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)
;; Key unmappings
(map! :leader "n" nil)
(map! :leader "o" nil)
i had this problem with doom, due to a keybinding conflict with
evil-jump-item. I fixed it by rebinding tab:
(map! :after evil-org
:map org-mode-map
:desc "org-cycle" :n [tab] #'org-cycle)

Emacs helm completion: how to turn off persistent-help_line?

I'd like to use helm as a drop-in replacement for display-completion-list.
The only issue is that it displays this line on top, which I don't want:
C-z: I don't want this line here (keeping session).
Here's the code to illustrate:
(helm :sources `((name . "Do you have?")
(candidates . ("Red Leicester"
"Tilsit"
"Caerphilly"
"Bel Paese"
"Red Windsor"
"Stilton"))
(action . identity)
(persistent-help . "I don't want this line here"))
:buffer "*cheese shop*")
I've tried setting persistent-help to nil, or not setting it at all, but it
still appears. How can I turn it off?
The attribute helm-persistent-help-string comes with the library helm-plugin. If you do not load it you get no help string. If you need to load helm-plugin for some reason you can disable the function helm-persistent-help-string afterwards by:
(defadvice helm-persistent-help-string (around avoid-help-message activate)
"Avoid help message"
)
If you want to remove the gray header line completely you can do:
(defadvice helm-display-mode-line (after undisplay-header activate)
(setq header-line-format nil))
With defadvice you change the behavior of helm globally.
If you want to change helm-display-mode-line just temporarily for the execution of your helm command you could use:
(defmacro save-function (func &rest body)
"Save the definition of func in symbol ad-func and execute body like `progn'
Afterwards the old definition of func is restored."
`(let ((ad-func (if (autoloadp (symbol-function ',func)) (autoload-do-load (symbol-function ',func)) (symbol-function ',func))))
(unwind-protect
(progn
,#body
)
(fset ',func ad-func)
)))
(save-function helm-display-mode-line
(fset 'helm-display-mode-line '(lambda (source)
(apply ad-func (list source))
(setq header-line-format nil)))
(helm :sources `((name . "Do you have?")
(candidates . ("Red Leicester"
"Tilsit"
"Caerphilly"
"Bel Paese"
"Red Windsor"
"Stilton"))
(action . identity)
(persistent-help . "I don't want this line here"))
:buffer "*cheese shop*"))
(Note, that stuff like cl-flet does not work this way.)

Use customization buffer to supply arguments to a function

I need to call a function interactively with a lot of arguments (it is 7 at the moment, but it will grow). Reading all the arguments in succession creates bad experience. For example, I am asking a user to input a class name. The class name can be fully qualified by the package it is in or not. So if a user thinks it must be fully qualified, and then I later ask them to provide the package name, there's no way for the user to go back and fix the error.
There are also many aspects of the input that are difficult to take care of at once. For instance, I need to make sure that certain characters don't appear in a certain pattern in the string being read etc. If the input fails validation on the last item of the input, it will feel frustrating for users to restart the whole procedure, while if I had a customization buffer at my disposal I could simply prevent them from committing the change if it doesn't validate and keep the already submitted good values.
tl;dr
I'm looking for a way to open customization buffer and read the user input into a function that is called interactively. Is there a way to do it?
I would recommend using the Emacs Widget Library instead of the customization buffer itself. Emacs info has an excellent section on the Widget Library. You can access it from emacs using C-h i m Widget RET. Or you can access the HTML version here. Here is the snippet of the widget example from the manual.
(require 'widget)
(eval-when-compile
(require 'wid-edit))
(defvar widget-example-repeat)
(defun widget-example ()
"Create the widgets from the Widget manual."
(interactive)
(switch-to-buffer "*Widget Example*")
(kill-all-local-variables)
(make-local-variable 'widget-example-repeat)
(let ((inhibit-read-only t))
(erase-buffer))
(remove-overlays)
(widget-insert "Here is some documentation.\n\n")
(widget-create 'editable-field
:size 13
:format "Name: %v " ; Text after the field!
"My Name")
(widget-create 'menu-choice
:tag "Choose"
:value "This"
:help-echo "Choose me, please!"
:notify (lambda (widget &rest ignore)
(message "%s is a good choice!"
(widget-value widget)))
'(item :tag "This option" :value "This")
'(choice-item "That option")
'(editable-field :menu-tag "No option" "Thus option"))
(widget-create 'editable-field
:format "Address: %v"
"Some Place\nIn some City\nSome country.")
(widget-insert "\nSee also ")
(widget-create 'link
:notify (lambda (&rest ignore)
(widget-value-set widget-example-repeat
'("En" "To" "Tre"))
(widget-setup))
"other work")
(widget-insert
" for more information.\n\nNumbers: count to three below\n")
(setq widget-example-repeat
(widget-create 'editable-list
:entry-format "%i %d %v"
:notify (lambda (widget &rest ignore)
(let ((old (widget-get widget
':example-length))
(new (length (widget-value widget))))
(unless (eq old new)
(widget-put widget ':example-length new)
(message "You can count to %d." new))))
:value '("One" "Eh, two?" "Five!")
'(editable-field :value "three")))
(widget-insert "\n\nSelect multiple:\n\n")
(widget-create 'checkbox t)
(widget-insert " This\n")
(widget-create 'checkbox nil)
(widget-insert " That\n")
(widget-create 'checkbox
:notify (lambda (&rest ignore) (message "Tickle"))
t)
(widget-insert " Thus\n\nSelect one:\n\n")
(widget-create 'radio-button-choice
:value "One"
:notify (lambda (widget &rest ignore)
(message "You selected %s"
(widget-value widget)))
'(item "One") '(item "Another One.") '(item "A Final One."))
(widget-insert "\n")
(widget-create 'push-button
:notify (lambda (&rest ignore)
(if (= (length (widget-value widget-example-repeat))
3)
(message "Congratulation!")
(error "Three was the count!")))
"Apply Form")
(widget-insert " ")
(widget-create 'push-button
:notify (lambda (&rest ignore)
(widget-example))
"Reset Form")
(widget-insert "\n")
(use-local-map widget-keymap)
(widget-setup))

Add button with dynamic menu to emacs's modeline?

I'm making my own minor mode for emacs. Now I want to add button to modeline. Click on this button must сause pop-up menu appear. The items of this menu depend on user's actions. I know that there is a way to add a function button to modeline with `minor-mode-alist', but I have no idea how to make dynamic menu.
Ok. Solution founded.:)
First: define some keymap:
(defconst my-mode-line-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line down-mouse-1]
(make-sparse-keymap))
map))
Second: append list with propertized string to modeline:
(setq global-mode-string
(append global-mode-string
(list
(propertize string-name
'local-map my-mode-line-map
'mouse-face 'mode-line-highlight))))
Third: Now you can add items with
(define-key my-mode-line-map
(vconcat [mode-line down-mouse-1]
(list some_generated_id_for_future_use))
(cons name function))
...and remove with
(define-key my-mode-line-map
(vconcat [mode-line down-mouse-1]
(list id_of_button_that_u_gave_when_add))
nil)
I found more proper way:
When you define minor mode, you can specify :lighter param
(define-minor-mode my-minor-mode
"docstring"
nil
:lighter (:eval (format "%s%.5s" "#" "some code if you want dynamic label"))
;or just string :lighter "static string"
:keymap my-minor-mode-map
... ... ... rest of code ....
then you can use easymenu:
(require 'easymenu)
(easy-menu-define my-minor-mode-menu
my-minor-mode-map
"Menu for my-minor-mode"
'("some text"
"-")) ;separator
; and then add menu items with easy-menu-add-item and remove with easy-menu-remove-item
; it's nothing hard. Read the docs ;)
This menu will be added to global menu-bar and it will pop up if you click on auto added(cause you specified :lighter param) minor-mode button on modeline.

Highlighting correctly in an emacs major mode

I am developing an emacs major mode for a language (aka mydsl). However, using the techniques on xahlee's site doesn't seem to be working for some reason (possibly older emacs dialect..)
The key issues I am fighting with are (1) highlighting comments is not working and (2), the use of regexp-opt lines is not working.
I've reviewed the GNU manual and looked over cc-mode and elisp mode... those are significantly more complicated than I need.
;;;Standard # to newline comment
;;;Eventually should also have %% to %% multiline block comments
(defun mydsl-comment-dwim (arg)
"comment or uncomment"
(interactive "*P")
(require 'newcomment)
(let
((deactivate-mark nil)
(comment-start "#")
(comment-end "")
comment-dwim arg)))
(defvar mydsl-events
'("reservedword1"
"reservedword2"))
(defvar mydsl-keywords
'("other-keyword" "another-keyword"))
;;Highlight various elements
(setq mydsl-hilite
'(
; stuff between "
("\"\\.\\*\\?" . font-lock-string-face)
; : , ; { } => # $ = are all special elements
(":\\|,\\|;\\|{\\|}\\|=>\\|#\\|$\\|=" . font-lock-keyword-face)
( ,(regexp-opt mydsl-keywords 'words) . font-lock-builtin-face)
( ,(regexp-opt mydsl-events 'words) . font-lock-constant-face)
))
(defvar mydsl-tab-width nil "Width of a tab for MYDSL mode")
(define-derived-mode mydsl-mode fundamental-mode
"MYDSL mode is a major mode for editing MYDSL files"
;Recommended by manual
(kill-all-local-variables)
(setq mode-name "MYDSL script")
(setq font-lock-defaults '((mydsl-hilite)))
(if (null mydsl-tab-width)
(setq tab-width mydsl-tab-width)
(setq tab-width default-tab-width)
)
;Comment definitions
(define-key mydsl-mode-map [remap comment-dwim] 'mydsl-comment-dwim)
(modify-syntax-entry ?# "< b" mydsl-mode-syntax-table)
(modify-syntax-entry ?\n "> b" mydsl-mode-syntax-table)
;;A gnu-correct program will have some sort of hook call here.
)
(provide 'mydsl-mode)
You have a couple of syntactic problems in your code, but you got it nearly correct. Here's my edited version which appears to do the right thing for a buffer in mydsl-mode:
; No changes to the simple vars
(defvar mydsl-events
'("reservedword1"
"reservedword2"))
(defvar mydsl-keywords
'("other-keyword" "another-keyword"))
;; I'd probably put in a default that you want, as opposed to nil
(defvar mydsl-tab-width nil "Width of a tab for MYDSL mode")
;; Two small edits.
;; First is to put an extra set of parens () around the list
;; which is the format that font-lock-defaults wants
;; Second, you used ' (quote) at the outermost level where you wanted ` (backquote)
;; you were very close
(defvar mydsl-font-lock-defaults
`((
;; stuff between "
("\"\\.\\*\\?" . font-lock-string-face)
;; ; : , ; { } => # $ = are all special elements
(":\\|,\\|;\\|{\\|}\\|=>\\|#\\|$\\|=" . font-lock-keyword-face)
( ,(regexp-opt mydsl-keywords 'words) . font-lock-builtin-face)
( ,(regexp-opt mydsl-events 'words) . font-lock-constant-face)
)))
(define-derived-mode mydsl-mode fundamental-mode "MYDSL script"
"MYDSL mode is a major mode for editing MYDSL files"
;; fundamental-mode kills all local variables, no need to do it again
(setq mode-name "MYDSL script")
;; you again used quote when you had '((mydsl-hilite))
;; I just updated the variable to have the proper nesting (as noted above)
;; and use the value directly here
(setq font-lock-defaults mydsl-font-lock-defaults)
;; when there's an override, use it
;; otherwise it gets the default value
(when mydsl-tab-width
(setq tab-width mydsl-tab-width))
;; for comments
;; overriding these vars gets you what (I think) you want
;; they're made buffer local when you set them
(setq comment-start "#")
(setq comment-end "")
(modify-syntax-entry ?# "< b" mydsl-mode-syntax-table)
(modify-syntax-entry ?\n "> b" mydsl-mode-syntax-table)
;;A gnu-correct program will have some sort of hook call here.
)
(provide 'mydsl-mode)