text:
How to properly auto-indent Org Mode multi-line list items?
I am typing a journal entry in org-mode as so:
I worked on my English paper today, and made lots of progress.
+ We used Emacs for our project
+ Some other people used vi, but I think Emacs Org mode really helps
  + One of the groups even used LaTeX, but I think Emacs AucTeX might be the best way to write LaTeX

This is what happens when I press RET between AucTeX and might.
I worked on my English paper today, and made lots of progress.
+ We used Emacs for our project
+ Some other people used vi, but I think Emacs Org mode really helps
  + One of the groups even used LaTeX, but I think Emacs AucTeX
might be the best way to write LaTeX

But why does it go back all the way to the very first column? I want might to be aligned with the word Org from the previous line... Would something like Fill-mode help here (never used it)? Right now I am just doing <space> however many times from the first column to align words in this case, but it is rather cumbersome. You would think TAB would work, but it doesn't seem to unfortunately..
What is the best way to maintain alignment in this case? Any help would be appreciated.
Edit: I would use auto-fill-mode, but I feel that sometimes it is too strict in making it's judgements.
Eg. say I have this paragraph as a list item:
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit some
  gibberish here. Phasellus sed massa quam. Morbi nec sollicitudin
  nulla. Ut pharetra lacinia hendrerit. Praesent purus ex, luctus non
  erat quis, interdum vulputate justo.

I usually like it when sentences are on one line. So I want the sentence "Lorem ipsum dolor sit amet, consectetur adipiscing elit some gibberish here." to be on the first line. However, since auto-fill-mode/M-q is strict, it won't allow me to do this.
I was wondering if there was a more general solution, like some hidden command I don't know about that creates a newline, but with the stuff after the newline being indented properly, just like M-q.

Hit M-q (fill-paragraph) instead of RET to get the effect you want.  Consider activating auto-fill-mode so this sort of thing happens automatically.

@FranBurstall Hmm, can you set auto-fill-mode to only be on in Org Mode and children only (org-journal is a child of org mode), instead of globally? Is this a good way to achieve this: (add-hook 'org-mode-hook 'auto-fill-mode)? I sort of realized that auto-fill-mode might be good, but was not sure how to enable it.

@FranBurstall I made some updates to the question to specify better what I'm looking for.

(1) Yr add-hook stanza is the right way to enable auto-fill-mode in just org buffers.  (2) Maybe newline-and-indent is what you are looking for.

newline-and-indent is probably the thing that you are looking for as @FranBurstall points out, but it is still buggy: it calls the value of indent-line-function which in Org mode buffers is org-indent-line. But org-indent-line seems buggy to me: in fact, the code and the description do not seem to match. I think a bug report to the Org mode mailing list is warranted.

@NickD Yes, it seems that, in Org mode (version 9.3), both newline and newline-and-indent seem to have the same behaviour (neither of which is what I am asking for in this question), which does seem like a bug. I'm not involved with the development for Org Mode - or any other many open source projects that use a mailing list - so am not familiar with how filing a bug report works. I would appreciate if you could open a bug report on my behalf.


text:
Vim-like EOL behavior in Emacs
I'm trying to get Emacs to imitate Vim's EOL behavior. Namely at the end of line ("\n"), the cursor comes to a halt instead of progressing to the start of the next line.
The following works fine and dandy but the cursor gets stuck before empty lines:
(defun make-eol-intangible ()
  (interactive)
  (add-hook 'post-command-hook
    (lambda ()
      (when (and (point) (looking-at "\n"))
        (backward-char)) t t)))

I could put an additional condition that tests for (point) looking-back however Emacs docs mention that looking-back should be avoided, and is possibly deprecated. On that note it's probably less optimal to use looking-at either.
I would like some suggestions.

Amended function (doesn't work as expected):
(defun make-eol-intangible ()
  (interactive)
  (add-hook 'post-command-hook
    (lambda ()
      (when (and (eq (char-before (point)) ?\n)
                 (eq (char-after (point)) ?\.))
    (backward-char)))))

(make-eol-intangible)

When should the cursor "come to a halt"? When forward-char is invoked? Why are you checking (point) in a condition? It will always return non-nil. looking-at uses regexps, but you don't need a regexp to detect a newline. following-char, char-after, preceding-char, and char-before can all be used to detect a newline character after or before point, respectively.

What @Basil said. Please try to clarify the behavior you want. Don't assume that readers will know what the Vim behavior is. Specify the desired behavior. That will help others help you better.

What was not so clear about this description? : "I'm trying to get Emacs to imitate Vim's EOL behavior. Namely at the end of line ("\n"), the cursor comes to a halt instead of progressing to the start of the next line."

@OS2 In Emacs, when point is at the end of the line, it does not progress to the start of the next line on its own. A key/command has to be invoked in order for point to move to the next line. So which key/command are you trying to customise in order for point not to move to the next line? In other words, please describe the sequence of keys/commands you would like to invoke and what you would like to see as a result of that key/command sequence. Otherwise what you are asking is not very clear.

There's a difference between EOL and \n. But when the editor reads a \n it sends the cursor to the next line. This is what I want to avoid. This problem doesn't seem to be as trivial as it sounds. I've been playing around with elisp and this is what I've come up with but it doesn't work. (when (and (eq (char-before (point)) ?\n) (eq (char-after (point)) ?\.)) (backward-char))

What do you mean by "the editor reads a \n" and "it sends the cursor to the next line"? What prompts the editor to read the "\n"? In what way does it send the cursor anywhere? What is prompting these operations? And why are you checking for a full stop ?. at point?

That's not a full stop.
https://www.emacswiki.org/emacs/RegularExpression

@OS2 Yes it is. char-after returns either a character integer or nil. eq on integers and symbols tests for object identity. ?\., usually written as ?., is a character integer with decimal value 46. Your second "amended function" example does not use any regexps. For information on Elisp regexps, I'd suggest the Elisp reference manual instead: (info "(elisp) Regular Expressions").

@OS2 Please extend your question with information on your motivation for this customisation, and precise details on how you intend to use it in practice. Otherwise it is confusing at best, and an example of an XY problem at worst.

Avoid using post-command-hook for this. Instead write your own forward char and backward char functions, and bind them to appropriate keys.

https://emacs.stackexchange.com/tags/elisp/info

Something along these lines.
(defun make-eol-intangible ()
  (interactive)
  (add-hook 'post-command-hook
    (lambda ()
      (when (and (eq (char-before (point)) ?\n)
                 (not (eq (line-end-position) (line-beginning-position))))
        (left-char)))))

Found a better solution:
(defun my-maybe-right ()
  "Move right if char at point is not a newline."
  (interactive)
  (unless (= (following-char) ?\n) (forward-char)))

(global-set-key [right] #'my-maybe-right)

(global-set-key [right] #'my-maybe-right) results in argument error unless I use
(define-key (current-global-map) [right] #'my-maybe-right).

How do you get the error? What's the error? How are you evaluating this? If you look at the definition of global-set-key (e.g. with M-x find-function RET global-set-key RET) you'll see it's doing the exact same thing.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Emacs ignore \n in buffer
I would like to change the default behavior in emacs when '\n' meta-characters are encountered by the cursor. The default behavior is such that at '\n',
(1) right-key sends the cursor to the beginning of the next line,
(2) up-key sends the cursor to the end of the prev line,
(3) down-key sends the cursor to the end of the next line.
How can I get emacs to ignore '\n' meta-characters in a given buffer? Or how can I get emacs to ignore either one of the keys identified in (1), (2) and (3)?

https://emacs.stackexchange.com/tags/elisp/info

You can reassign the keys to new functions that don't move if the char at point is a newline:
(defun maybe-down ()
  "Move down if char at point is not a newline."
  (interactive)
  (if (char-equal (char-after) 10) (ignore) (next-line)))
(define-key (current-local-map) [down] 'maybe-down)

And similarly for [right] with (right-char).

Thanks for the suggestion. This fails to run emacs 27. Fails next-line check. Fails define-key: Wrong type argument: keymapp, nil

The nil means there's no local map. You can define one, or turn on a major mode to establish one. I don't know what you mean by "fails next-line check".

Yes it's working as expected. Thank you. However, why do I get Invalid function: (ignore) when this condition gets satisfied:  (if (char-equal (char-after) 10) ((ignore) (next-line)) (forward-char)))

Seems I can ignore the ignore next-line completely and have just: (if (char-equal (char-after) 10) () (forward-char)))

@OS2: I wrote (ignore), not ((ignore) ...

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to modify text that's yanked?
I copy text from websites and paste/yank into emacs buffers. But this text sometimes has silent hyphens in them. The behaviour when copying and pasting text with soft hyphens in it varies across applications, but for emacs (on Windows), it seems to paste the text including the soft hyphens. I want it to not include the soft hyphens.
What I've been doing right now is a manual M-x replace-string where I paste in the soft-hyphen to be replaced with nothing.
Is there a way to have emacs automatically replace soft-hyphen with nothing after a yank? Is there a hook to use?

There is a variable named interprogram-paste-function that is bound to the function that retrieves the value from the system.
You can define your own function that calls the original function and remove the hyphens, and bind it to this variable.
The package https://github.com/Lindydancer/highlight2clipboard does similar things, although it modifies things copied from Emacs to the outside world.


text:
How to add -shell-escape option to latex compile command
Background story:
I have to compile my LaTeX document with the -shell-escape command line option because the pgfplots library I am using calls gnuplot. This was necessary to get a plot of a recursive function requiring double precision fpu.
Problem:
When I hit C-c C-C or C-c C-f in emacs (GNU Emacs 26.3) the document is compiled using pdflatex \\nonstopmode\\input mydoc.tex but the plot in the PDF output document stays empty, because of some restrictions. When I compile manually using pdflatex -shell-escape \\nonstopmode\\input mydoc.tex everything works just fine.
Failed attempts:
I have set tex-start-options variable in the 'tex run group' to "-shell-escape", but it did not appear in the tex-shell.
Update:
Meanwhile I have installed AUCTeX as suggested.
I am still curious to find out how the issue can be solved without it.

See my answer for possible gotcha's in setting tex-start-options, but that should work.

By any chance have you set latex-run-command? I think I've found a bug.

For the built-in TeX mode (i.e. not AucTeX), you can customize the variable tex-start-options: do C-h v tex-start-options and hit the Customize link. Enter --shell-escape as the value string, hit Apply or Apply and Save and try C-c C-c in your TeX file again.
EDIT: I see you said you tried this. I did too and it works fine. Maybe you didn't apply the customization? BTW, you can only tell by looking at the command at the top of the resulting *tex-shell* buffer: the prompt still says pdflatex (or whatever).

Shouldn't it be -shell-escape?

The AucTeX equivalent is TeX-command-extra-options.

@young_souvlaki: both versions work AFAIK with every processor (pdflatex, xelatex, lualatex). The usual convention is a double dash for long options and a single dash for short options, so I try to encourage the universal adoption of that convention :-)

Yea I like that thinking, -shell-escape does look odd.

I haven't had any luck with tex-start-options in latex-mode. It seems to ignore the setting.

My favourite solution :
I have composed this small function in my init file that I find convenient.
      (defun TeX-command-toggle-shell-escape ()
    "toggles the option --shell-escape from the tex command"
            (interactive)
            (setq TeX-command-extra-options
                  (cond ((string-match-p "\\_<--shell-escape\\_>" TeX-command-extra-options )
                         (replace-regexp-in-string "\\_<--shell-escape\\_>" "" TeX-command-extra-options))
                        ((string-empty-p TeX-command-extra-options)"--shell-escape")
                        (t(format "--shell-escape %s" TeX-command-extra-options))))
            (message "TeX-command-extra-options : `%s'" TeX-command-extra-options))

You can bind it to "C-c C-t C-x" (for instance).'
Using the package bind-key syntax :
    (bind-key "C-c C-t C-X" #'TeX-command-toggle-shell-escape  LaTeX-mode-map)

So, the key sequence "C-c C-t C-x" activates or deactivates the shell-escape option.
Other solution :
You can add a local variable to your source file
    % Local Variables:
    % TeX-command-extra-options: "-shell-escape"
    % End:

But the file has to be reloaded to activate the variable - or you can do M-x normal-mode instead.

Thanks for your instant reply. I've copied your local variable solution to the end of my document adding % mode: tex. When I reloaded it, there was a warning about possibly dangerous options and I had to confirm, what I did. But still -shell-escape is not added to to the command appearing in the tex-shell buffer. I can't find TeX-command-extra-options in the variable documentation. Could it be that it does not exist an my system?

Mode should be LaTeX, it is default using AUCTeX. Are you using AUCTeX ?

No, sorry I am not using AUCTeX - just ordinary tex-mode and company.

Thats not incompatible. AUCTeX is for Emacs, pdftex is for TeXLive. To install AUCTeX on Emacs : M-x package-install RET auctex RET. Or check C-h v AUCTeX-version if installed

I got aware of the misunderstanding as soon I hit the add-comment button. I've edited the original comment.

Sorry, I cant help, I do not use ordinary tex-mode.

I've installed AUCTeX. Compilation works just fine now. Thanks for your effort.

If this solution works for you, you could check it. It might help others.

|I use this minor mode:
(define-minor-mode tex-command-shell-escape-mode
    "Enable compilation with -shell-escape"
    :init 1
    :lighter " -shell-escape"
    (setq  TeX-command-extra-options
           (if (string-empty-p  TeX-command-extra-options)
               "-shell-escape"
             "")))

You can bind it to C-c C-t C-x for instance to toggle the shell-escape mode.
(bind-key "C-c C-t C-X" #'tex-command-shell-escape-mode LaTeX-mode-map)

This probably shouldn't work properly if you're using TeX-command-extra-option for some other purpose elsewhere. It's not my case.


text:
How can I get rid of `Loading /home/user/.emacs.d/package.el (source)...done` message after installing a package manually?
I'm trying to install this package manually, adding the org-bullets.el file to my emacs directory.
As suggested, I enabled it adding
(load-file "~/.emacs.d/org-bullets.el")

(require 'org-bullets)

(add-hook 'org-mode-hook #'org-bullets-mode)

to my init.el
The program works but now when I start Emacs the mini buffer always shows this message:
Loading /home/user/.emacs.d/org-bullets.el (source)...done
How can I get rid of it?
I'm running Emacs 27.2

You can crib the load-file function and replace it with a silent version.
The load-file function looks like this (just do C-h f load-file and then click on the link of the file that contains it (files.el) to see the definition of the function):
(defun load-file (file)
  "Load the Lisp file named FILE."
  ;; This is a case where .elc and .so/.dll make a lot of sense.
  (interactive (list (let ((completion-ignored-extensions
                            (remove module-file-suffix
                                    (remove ".elc"
                                            completion-ignored-extensions))))
               (read-file-name "Load file: " nil nil 'lambda))))
  (load (expand-file-name file) nil nil t))

As you can see, it calls load. If you examine the doc string of load it says:

(load FILE &optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)
...
Print messages at start and end of loading unless
optional third arg NOMESSAGE is non-nil (but ‘force-load-messages’
overrides that).

force-load-messages is nil by default (but check your configuration with C-h v force-load-messages to make sure). Assuming that's the case, all you need to do is define your own load-file function early in your init file (before you use it to load org-bullets), but when your function calls load, change it so that the nomessage parameter is t instead of nil:
(defun load-file (file)
  "Load the Lisp file named FILE."
  ;; This is a case where .elc and .so/.dll make a lot of sense.
  (interactive (list (let ((completion-ignored-extensions
                            (remove module-file-suffix
                                    (remove ".elc"
                                            completion-ignored-extensions))))
               (read-file-name "Load file: " nil nil 'lambda))))
  (load (expand-file-name file) nil t t))

Thanks!!! The message now is gone.


text:
Customizing faces of tab-line
I've been trying to get tabs showing up on emacs, and I came across the builtin tab-mode.
I'm trying to set colors and make it look decent, and I ended up here, which told me to modify tab-line-.+ with set-face-attribute.
So I appended this to my init.el:
(set-face-attribute 'tab-line nil
                    ;; some omitted settings, background, foreground, font
)

(set-face-attribute 'tab-line-tab-inactive nil
                    ;; again, a bunch of omitted settings
)

When I load the config, I get the error: "Invalid face: tab-line-tab-inactive".
The face does seem to be present in the tab-line.el in the source. What's going on? Thanks!

It may be that set-face-attribute hasn't run yet? Perhaps this is an occasion for with-eval-after-load? Do you have helm-faces? If so what happens if you do M-x helm-faces and search for tab-line? Do you see tab-line-inactive then?

As @CalebJay suggests, these things are only defined after loading tab-line.el, so (with-eval-after-load "tab-line.el" (set-face-attribute 'tab-line nil) (set-face-attribute 'tab-line-tab-inactive nil)) should do  the job.


text:
What is this gap, and how do I remove it?
I'm changing the appearance of the tab-bar, and I have the following:

There's a gap present between tabs and between the left edge of the frame, despite setting the face attribute :box to nil on tab-bar-tab and tab-bar. What is this gap, what face does it belong to, and how can I remove it?
Edit: changing the backrgound color of the tab-bar face to match the background color of the tab-bar-tab face 'fixes' the issue in that I can no longer see the gap, but I'd still like to know how to fully remove the gap.

It's a separator.  It separates tabs as well as the first tab from the window edge. You can either set tab-bar-separator to an empty string, thus losing the separator between tabs too. Or just remove the first separator with
(advice-add 'tab-bar-format-tabs :around
  (lambda (orig-fun)
    (cdr (funcall orig-fun))))


text:
How this guy do glow(neon) text
I think everything is clear from this video.
https://vimeo.com/22798433
I am interested in how to make the text exactly like that.
Here's another example but this is vs code
https://youtu.be/cxjP4731Av8?t=111

you could have a look at the emacs-live config used in the video, or more generally use a terminal emulator with graphic effects like cool-retro-term and run emacs from a shell.


text:
Display the header that a TODO item belongs to?
In org mode, I'll have a file pertaining to some topic, and a few top level headings pertaining to instances of that topic, which may contain TODOs (also potentially nested). In the global TODO list, TODOs show up like this:
<file-name>:     <state> <name>

Would it be possible to instead display them like this (potentially with a custom format string):
<header> (<file-name>):      <state> <name>

Thanks!

See also :PROPERTIES: :CATEGORY: Foo :END:  under any given heading to have that show up in the Agenda...

Customize the todo part of org-agenda-prefix-format and add the breadcrumbs placeholder %b. For example, by default org-agenda-prefix-format has the value

((agenda . " %i %-12:c%?-12t% s")
 (todo . " %i %-12:c")
 (tags . " %i %-12:c")
 (search . " %i %-12:c"))

and a TODO entry for a second-level Home headline under a top-level Tasks headline, looks like this:

Home:       TODO Work on music DB

If you change the todo entry in org-agenda-prefix-format from " %i %-12:c" to " %b %i %-12:c", the same entry is shown as

Tasks->  Home:       TODO Work on music DB

Breadcrumbs include all the higher level headlines.
In order to do the above change, first do C-h v org-agenda-prefix-format, and click on the customize link. In the resulting display, the values can be edited directly: find the todo entry and its format and change it as above. Then click Apply to try it out or Apply and Save to save it for future sessions as well.


text:
Cons interpolation
I want to be able to write a cons with some of the cells being placeholders for later evaluation. I know I can use backquote constructs, but it tries to evaluate the cons immediately.
To clarify, provided I have a variable my-value, I could do:
(setq my-cons `(my-key ,my-value))
But this won't satisfy my needs, as it's evaluated immediately. I can't use my-cons, without knowing about its structure, to create another cons like '(my-key "another-value"). I need to be able to provide the structure as a variable, and fill it with real data later.
Think about format function: We define a string, with some placeholders, and then use format to inject our data into the string. What I need, is analogous to a format string, but for cons.
Detailed use-case:
I want to convert a org-mode todo entry to a Jira ticket. org-jira and ejira, both have a shortcoming: they only read some basic data (project, ticket type summary).
Since Jira is customizable, each project could have its different set of required fields. A useful org-todo-to-jira would allow you to define a mapping between org properties, and Jira fields. I want my org DEADLINE to be interpreted as
{
  duedate: "deadline-value-here"
}

and my :estimation: to be interpreted as
{
  estimation: {
    originalEstimation: "estimation-value-here"
  }
}

But a user might want another mapping. The cleanest thing that I thought of, was an alist defined by defcustom: the car of each cell being a property, and the cdr being another cons, defining the structure for that field: telling us how that field should be converted to a json. The car lets me know where to find that property in org todo entry, and the cdr lets me know where should I put that value in my json.

I don't understand the question.  What do you mean by "reusable"?  When do you "need it to" be evaluated?  Most importantly, what's an example of something you want to do but can't?  (Could you show some pseudo-code which indicates how you wish things worked?)

Sorry for the ambiguity, I've updated the quetsion.

I still don't understand.  My best guess is that you should define a function which generates and returns a cons?

Oh :D A function won't do the job, cause I still need to know how should I interpret the value. Some values should be interpreted like '(my-key my-value), some values should be interpreted like '(my-key '(id my-value)) and so forth. I need to get a structure, and put the value in that structure.

I need to know how should I define a cons with some placeholders, that will be eventually replaced with actual data. My first thought was putting something like :placeholder: in cons, and then recursively search for :placeholder: and replace it with a value. But I think there should be a better, more efficient way.

https://emacs.stackexchange.com/tags/elisp/info

The question is unclear (to me). So far, it seems like just using the backquote form that you show is the answer. Where, how, and when variable my-value is bound or set is something else - do that any way and any place you like.

Your question is really too vague to have a proper answer, but you will probably end up using either a function or a macro. I would start by writing out the data structure explicitly each time it is needed. Later you may find a nicer way to construct it, but when you are first writing a program it is not a good idea to get hung up on such details. Note that if you are querying a database, the database library may provide some tools you can use.

@Drew I think the elisp tag was relevant. My question was not about customizing emacs, nor it was specifically about the application I'm writing. It was a question about doing something purely elisp-related. Anyway, I found a way of doing it, I hope it clears up what I was trying to do. I've also updated the question and clarified it as best as I could. I agree it was too cryptic (hopefully, now it's less cryptic). Thank you for your answers.

(1) Please read the tag description again. The tag is not for "doing something" with Elisp. (2) And no, for me anyway, your answer doesn't clear up what you're trying to do.

I ended up doing this:
If I set a my-cons variable like this:
(setq my-cons '`(my-key ,placeholder))
Whenever I want to replace placeholder with something else, I could do(eval my-cons))
(let ((placeholder "my-value"))
  (print (eval my-cons)))

;; prints (my-key "my-value")

Why on earth would you write this rather than (defun my-cons (argument) (cons 'my-key argument)), or if you really want to hard-code the name placeholder, (defun my-cons () (cons 'my-key placeholder))? Neither your question nor the comments under it make it clear what you want, but I can't imagine a question where this would be a reasonable answer.

Because I can't make any assumption about the cons structure. What I was trying to do, was getting some data from org-mode properties, and adding them to nested json. Why would I write a function for every possible configuration? In this way, I only make a mapping between org-mode property names and how their value is to be structured.

I did ask for an example of what you were trying to do, and "getting some data from org-mode properties, and adding them to nested json" is the closest you've come to providing that example.  If you had said that and then provided the pseudo-code showing how you wished it worked, and why your existing code was not satisfactory, people could have provided answers.  As it was, your edits were all very abstract and unclear, and I still don't know where you've having a problem, so perhaps you could go ahead write up that example in detail.

@phils I want to convert a org-mode todo entry to a Jira ticket. org-jira and ejira, both have a shortcoming: they only read some basic data (project, ticket type summary). Since Jira is customizable, each project could have its different set of required fields. A useful org-todo-to-jira would allow you to define a mapping between org properties, and Jira fields. I want my org DEADLINE to be interpreted like {duedate: "deadline-value-here"}, and my :estimation: to be interpreted like {estimation: {originalEstimation: "estimation-value-here"}}. But a user might want another-

-mapping. The cleanest thing that I thought of, was a alist defined by defcustom: the car of each cell being a property, and the cdr being another cons, defining the structure for that field: telling us how that field should be converted to a json. The car lets me know where to find that property in org todo entry, and the cdr lets me know where should I put that value in my json.

Please add that description to the question: that's where it belongs, not in a comment. The more information you can provide in the original question, and the more concrete that information is, the better your chances of getting a good answer. You might also want to read this page: https://emacs.stackexchange.com/help/how-to-ask

@NickD I've edited my question, and clarified it as best as I could. If it's still vague, then sorry, I've already found my answer, and don't want to waste anybody's time. Thank you all.

Well I still think you want a function. Keep your alist for mapping things to other things, but write a function (one function, which you can call for each of the properties in turn), which takes the input, processes it with the alist, and returns the output.

I agree with @phils's last comment: this sounds like  a simple template engine. Does it have to be done in emacs? If not, you might want to investigate something like Jinja2

I'd already developed most parts of that function, but this was the missing piece. And yes, it has to be in emacs, as the whole point is improving the integration of org-mode with Jira.


text:
Org Tangle if file does not exist
I've been trying to work out if it's possible to tangle a file if it's not existent on the system.  I came across Can Org Babel conditionally tangle code blocks based on system-type? which gave me a starting point, however when I do the following
#+begin_src shell :tangle (when (not (file-exists-p "~/bin/eto")) ~/bin/eto)
I get Wrong type argument: stringp, nil when I try to tangle the src block.
What am I doing wrong?

I'm confused. Do you want to tangle that shell block to ~/bin/eto? Then you simply need #+begin_src shell :tangle ~/bin/eto, right?

https://emacs.stackexchange.com/tags/elisp/info

@aadcg I only want it tangled when the file doesn't exist, so when I set up on a new system for the first time the src block will get tangled and no other time when I make changes to my config.

@dalanicolai's answer is correct but you still have a problem: the legal values of the :tangle header are the strings yes, no or a filename, (IOW, the argument always has to be a string), so your elisp snippet has to be more complicated:
#begin_src  shell :tangle (if (not file-exists-p "foo") "foo" "bar")
...

Your original snippet returns nil if the file exists, but nil is not a string. The modified snippet returns the string foo if foo does not exist, but it returns the string bar otherwise, so the :tangle header always gets a string argument and everybody is happy.
EDIT: The OP in a comment to the question mentions that the tangling should only happen the first time (i.e. when the file does not exist) and never again. So the header should read:
#begin_src  shell :tangle (if (not file-exists-p "foo") "foo" "no")
...

That would make sense. Thank you both NickD & dalanicolai

If this or the other answer has answered your question, please accept one or the other to indicate to others that there is an answer. Don't leave questions orphaned if at all possible.

From the org-documentation we find that the filename should be passed as a string (see section FILENAME), so you should place the latter ~/bin/eto between double quotes also.


text:
How to make backward-kill-word and kill-word stop after it kills a newline character?
kill-word and backward-kill-word deletes too much text:
foo(bar)
    <point>

Now if I press C-<backspace>:
foo(<point>

What I want is:
foo(bar)<point>

after pressing C-<backspace>, just like how the other editors do.
EDIT: Based on the answer from @gigiair, I'm trying to implement the command sequency in elisp, but I'm getting "Wrong number of arguments" when executing the code:
(defun leo/backward-kill-word ()
  "Better backward-kill-word."
  (interactive)
  (set-mark-command)
  (backward-sexp)
  (forward-sexp)
  (backward-delete-char-untabify))

I'm new to elisp, know nothing about.

https://emacs.stackexchange.com/tags/elisp/info

What other editors? E.g. vim does not do that when I use C-<backspace> either in insert or in edit mode.

set-mark-command takes an argument (see its doc string with C-h f set-mark-command). *BUT* you should *not* use set-mark-command(orset-mark) from lisp: it's supposed to be used interactively. See the doc string of set-markwithC-h f set-mark`.

And BTW, backward-delete-char-untabify also takes an argument, but you probably shouldn't be using that either. Using delete-region (or kill-region depending on whether you do not or you do want to keep the contents of the region in the kill-ring) as in the answer below is a much better way. But I don't think that the sexp motion commands are appropriate for this problem.

This sequence does it :
 C-SPC                      ;; set-mark-command
 C-M-b                      ;; backward-sexp
 C-M-f                      ;; forward-sexp
 <backspace>                ;; backward-delete-char-untabify

This function executes this code :
(defun leo/backward-kill-word ()
  "Better backward-kill-word."
  (interactive)
  (let((beg (point)))
      (backward-sexp)
      (forward-sexp)
      (delete-region beg (point))))

This function is probably better
(defun leo/backward-kill-word ()
      "Better backward-kill-word."
      (interactive)
      (fixup-whitespace)
      (backward-delete-char-untabify 1))

I'm trying to create a command for this, but I'm getting "Wrong number of arguments" when I execute. See the elisp code I added to my question. I'm new to elisp.

The sexp commands are probably a bad idea: they move the cursor across a "balanced" expression. Try getting rid of the opening paren in the OP's test and see what happens. It is better to acknowledge first that what the OP wants is not a "better" backward-kill-word but a different function altogether, one that deletes (or perhaps kills) whitspace backwards until something happens (the OP has not made clear what that is: the example seems to indicate that he wants to reach the first non-whitespace character, but the title of the question says differently).

@maverick1013 read the recommendation for novice in (describe-function 'set-mark-command)


text:
How to write an elisp function to insert some text at the beginning and end of a selected region?
More specifically, I want to do something like this:
Select some region,
<mark>
int foo(int bar)
{
    bar = do_something(bar);
    return bar + 1;
}
<point>

and then type a command to do like this:
#if 0
int foo(int bar)
{
    bar = do_something(bar);
    return bar + 1;
}
#endif

Write an #if 0 at the beginning of the region, and an #endif at the end. But it could be any arbitrary string really, even /* and */ to comment out the region.

https://emacs.stackexchange.com/tags/elisp/info

Thanks to some nice guy at the Doom Emacs discord server, I got it working:
(defun leo/c-if-0-region (beg end)
  (interactive "r")
  (save-excursion
    (narrow-to-region beg end)
    (set-mark nil)
    (goto-char (point-min))
    (insert "\n#if 0\n")
    (goto-char (point-max))
    (insert "\n#endif\n")
    (widen)))


text:
Unable to setup lsp-mode with lsp-pyright
I'm using Emacs 28.1 on macOS 11.6.6 (installed with brew) and want to setup a Python IDE with lsp-mode and lsp-pyright.
My (not full) init.el looks like this (LSP and Python setups are at the bottom of the file):
;; Define and load custom.el file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

;; Modify package repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Load and activate Emacs packages
(package-initialize)

;; Install use-package if it's not installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Load use-package
(require 'use-package)
(setq use-package-hook-name-suffix nil) ;; Do not append text to the name of hooks mentioned by :hook

;; Load use-package-ensure
;; Support for :ensure and :pin keywords in use-package declarations
(require 'use-package-ensure)
(setq use-package-always-ensure t)

;; exec-path-from-shell
(use-package exec-path-from-shell
  :ensure t
  :if (eq system-type 'darwin)
  :custom
  (exec-path-from-shell-variables
   '("PATH" "MANPATH" "XDG_CONFIG_HOME" "WORKON_HOME" "LSP_USE_PLISTS" "PYTHONPATH" "IPYTHONDIR" "MPLCONFIGDIR"))
  (exec-path-from-shell-arguments nil)
  :config
  ;; (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/lib/pkgconfig"))
  (exec-path-from-shell-initialize))

;; Helm
;; Input completion
(use-package helm
  :ensure t
  :init
  (helm-mode 1)
  (require 'helm-config)
  :bind
  ;; ("C-c i"   . helm-imenu) ;; Select document heading
  ("C-x b"   . helm-mini) ;; Select buffers
  ("C-x C-f" . helm-find-files) ;; Open or create files
  ("C-x C-r" . helm-recentf) ;; Select recently saved files
  ("M-x"     . helm-M-x) ;; Evaluate functions
  ("M-y"     . helm-show-kill-ring) ;; Show the kill ring
  (:map helm-map
    ("<tab>" . helm-execute-persistent-action)
    ("C-z" . helm-select-action)))

;; which-key
;; Input completion
(use-package which-key
  :ensure t
  :custom
  (which-key-idle-delay 0.5)
  (which-key-idle-secondary-delay 0.5)
  :config
  (which-key-mode 1)
  (which-key-setup-side-window-bottom))

;; Company
;; Text completion
(use-package company
  :ensure t
  :custom
  (company-idle-delay 0.0)
  (company-minimum-prefix-length 4)
  (company-selection-wrap-around t)
  :hook
  ((text-mode-hook . company-mode)
   (prog-mode-hook . company-mode))
  :bind
  (:map company-active-map
    ("<tab>" . nil)
    ("TAB" . nil)
    ("M-<tab>" . company-complete-common-or-cycle)
    ("M-<tab>" . company-complete-selection)))

;; Flyspell
;; Spell checking for text (requires aspell)
(use-package flyspell
  :ensure t
  :init
  (setq ispell-program-name "aspell")
  :hook
  ((text-mode-hook . flyspell-mode)
   (prog-mode-hook . flyspell-prog-mode))
  :bind
  ("<f7>" . flyspell-word)
  ("M-<f7>" . flyspell-buffer))

;; Flycheck
;; Spell checking for code
(use-package flycheck
  :ensure t
  :init
  (setq flycheck-highlighting-mode 'symbols
    flycheck-indication-mode 'left-fringe
    flycheck-standard-error-navigation t)
  :hook
  (prog-mode-hook . flycheck-mode))

;; LSP Mode
;; Language Server Protocol Support
(use-package lsp-mode
  :ensure t
  :hook
  (lsp-mode-hook . lsp-enable-which-key-integration)
  :bind
  ("s-l" . lsp-keymap-prefix)
  :commands lsp)

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :hook
  (lsp-mode-hook . lsp-ui-mode)
  :bind
  (:map lsp-ui-mode-map
    ("C-c i" . lsp-ui-menu)))

(use-package lsp-pyright
  :ensure t
  :after (python lsp-mode)
  :custom
  (lsp-pyright-venv-path (getenv "WORKON_HOME"))
  :hook
  (python-mode-hook . (lambda ()
            (require 'lsp-pyright) (lsp))))

;; Python
(use-package python
  :ensure t
  :custom
  ;; (python-shell-completion-native-enable nil)
  (python-indent-guess-indent-offset-verbose nil)
  (python-shell-buffer-name "IPython")
  (python-shell-interpreter "ipython")
  (python-shell-interpreter-args "-i --simple-prompt")
  :hook
  ((python-mode-hook . flyspell-prog-mode)
   (python-mode-hook . flycheck-mode)
   (python-mode-hook . company-mode)
   (python-mode-hook . lsp)))

;; pyenv-mode
;; Integrate pyenv with python-mode
(use-package pyenv-mode
  :ensure t
  :if (eq system-type 'darwin)
  :after python
  :hook
  (python-mode-hook . pyenv-mode))

;; pyvenv
;; Python virtual environment support
(use-package pyvenv
  :ensure t
  :after python
  :custom
  (pyvenv-workon "env")
  :hook
  ((python-mode-hook . pyvenv-mode)
   (pyvenv-post-activate-hooks . pyvenv-restart-python)
   (pyvenv-post-deactivate-hooks . pyvenv-restart-python))
  :config
  (defalias 'workon 'pyvenv-workon)
  (defalias 'deactivate 'pyvenv-deactivate))

;;; init.el ends here

Basically, I use pyenv to manage different Python versions on my machine.
I also manage virtual environments under WORKON_HOME, which is defined in my .profile file as ~/.python/venv.
Generally, I use just a single venv called env for all my scripting purposes.
My goal is to use LSP for Python whenever I open a .py file.
According to this, lsp-mode and lsp-pyright are the only necessary parts to run LSP for Python in Emacs.
Now, in my current setup, whenever I run Emacs (from Applications) and open a .py file, I get this in my minibuffer:
Unable to find installed server supporting this file. The following servers could be installed automatically:

The only possible choice I have is pyright (it seems that it doesn't find lsp-pyright).
I choose it, press Enter and get the following message in *Messages* buffer:
LSP :: Download pyright started.
LSP :: Server pyright install process failed with the following error message: Unable to find a way to install pyright.
Check `*lsp-install*' and `*lsp-log*' buffer.

The *lsp-log* looks like this:
Command "pyls" is not present on the path.
Command "pylsp" is not present on the path.
Unable to install pyright via `npm' because it is not present

Why is it not finding my lsp-pyright installation?
Perhaps I am missing something on Python's side (some packages, etc.)?
Sidenotes:

I use (setq use-package-hook-name-suffix nil) so all of my :hook
definitions involve -hook(s) at the end.
As I understand, pyls (also know as python-language-server) is deprecated.

UPDATE:
All I needed to do to solve this problem was to install the actual language server for Python.
I did this by using brew, as pyright is available there:
brew install pyright

I tried your config, and it works for me. You can see the below figure. I faced an issue in using helm, so I disabled only the use-package declaration.

The relevant error is "npm because it is not present", which is what is used by lsp-mode or lsp-install-sever to install many language servers, including pyright. You can use the following link to install npm on your preferred OS (I am assuming Ubuntu).
How to Install Node.js and npm on Ubuntu 20.04
Note that you can also install pyright by yourself globally so that it is available in your $PATH. Then, lsp-mode clients will no longer try to install the server on your behalf. You can do either of the following:
npm install -g pyright
# If you prefer snap: https://snapcraft.io/
sudo snap install pyright --classic

Oh, so this clears things up a bit as I was actually missing something (the npm part). For me personally, various documentations I read were very unclear as to what I actually need in order make this setup work (I have never heard about npm up until today). Anyway, thanks for clearing this up!

Nice. You may want to accept and upvote the answer.


text:
regexp fails over expression involving {}
Over:
\includepdf[pages={1-}]{example-image-a.pdf}

I do / get
M-x query-replace-regexp \\includepdf[pages={1-}]{.*} → \\includepdf[pages={1-}]{TEST}
Replace 0 occurrences

The problem comes from the trailing {}.

In fact, the problem comes from the unescaped [ and ].
M-x query-replace-regexp \\includepdf\[pages={1-}\]{.*} → \\includepdf[pages={1-}]{TEST}

works for me.


text:
Org-mode how to write addr block and export to pdf correctly
Try to get a kind of letter with the sender on left side and the receiver on right side. I can use "indent to" that's ok in Emacs but when exporting to html or pdf the indentation characters are swiped out .. Can someone tell me how to get this working in pdf, html or odt format ? Thk
Org-mode with "indent to" picture ..  Pdf result ..
FWIW, this is a verbatim reproduction of https://stackoverflow.com/questions/72755221/org-mode-how-to-write-addr-block-and-export-to-pdf-correctly

There are three different ways to get side-by-side text

Using Verse Blocks, with Tabs to separate out the columns
Using Tables
Using Textboxes (within Tables)

I will outline the solution for each of the methods.  The solution I outline will be for ODT export using the the /enhanced/ ODT exporter.  Note that this exporter is NOT part of standard Emacs / Org mode. So, it has to be installed separately.  See Installation Instructions for more details.
The second and third examples uses Transcluded Tables.  So, you need to do enable it explicitly with
(add-to-list 'org-odt-experimental-features
         'transclude-sole-footnote-references-in-a-table)

Side-by-side text using Verse Blocks
To get this

do this
(Note that there are tab characters in the verse block below)

#+odt_preferred_output_format: pdf

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="MyOrgVerse"
             style:parent-style-name="Standard"
             style:family="paragraph">
  <style:paragraph-properties fo:margin-bottom="0.199cm"
                              fo:margin-top="0cm">
    <style:tab-stops>
      <style:tab-stop style:position="11cm" />
    </style:tab-stops>
  </style:paragraph-properties>
</style:style>
#+end_src

#+ATTR_ODT: :style "MyOrgVerse"
#+begin_verse
Free Software Foundation             The Linux Foundation
51 Franklin Street, Fifth Floor      548 Market St
Boston, MA 02110                     PMB 57274
USA                                  San Francisco, California
                                     94104-5401 US
#+end_verse

Proident, excepteur ea aliqua commodo qui duis officia cupidatat
consectetur velit sint dolore ullamco.  Eiusmod velit esse aliqua sint
et culpa proident, in pariatur laborum fugiat laborum lorem mollit
est.  Reprehenderit ipsum consequat lorem est labore amet, quis ut eu
mollit reprehenderit proident, incididunt aute reprehenderit.  Do
commodo in nostrud occaecat adipiscing tempor lorem sint nulla anim
aliqua sint.  Veniam, sunt quis excepteur ut lorem tempor ad.

Side-by-Side text using a Table
To get this

do this

#+odt_preferred_output_format: pdf

#+ATTR_ODT: :col-cookies "|2|1|"
| [fn:1] | [fn:2] |

Proident, excepteur ea aliqua commodo qui duis officia cupidatat
consectetur velit sint dolore ullamco.  Eiusmod velit esse aliqua sint
et culpa proident, in pariatur laborum fugiat laborum lorem mollit
est.  Reprehenderit ipsum consequat lorem est labore amet, quis ut eu
mollit reprehenderit proident, incididunt aute reprehenderit.  Do
commodo in nostrud occaecat adipiscing tempor lorem sint nulla anim
aliqua sint.  Veniam, sunt quis excepteur ut lorem tempor ad.

[fn:1]

Free Software Foundation\\
51 Franklin Street, Fifth Floor\\
Boston, MA 02110\\
USA

[fn:2]

The Linux Foundation\\
548 Market St\\
PMB 57274\\
San Francisco, California\\
94104-5401 US

Side-by-Side Text using Textboxes in a Table
To get this

do this

#+odt_preferred_output_format: pdf

| [fn:1] | [fn:2] |

Proident, excepteur ea aliqua commodo qui duis officia cupidatat
consectetur velit sint dolore ullamco.  Eiusmod velit esse aliqua sint
et culpa proident, in pariatur laborum fugiat laborum lorem mollit
est.  Reprehenderit ipsum consequat lorem est labore amet, quis ut eu
mollit reprehenderit proident, incididunt aute reprehenderit.  Do
commodo in nostrud occaecat adipiscing tempor lorem sint nulla anim
aliqua sint.  Veniam, sunt quis excepteur ut lorem tempor ad.

[fn:1]

#+ATTR_ODT: :style "OrgTextBoxFrameFlushLeft"
#+begin_textbox
Free Software Foundation\\
51 Franklin Street, Fifth Floor\\
Boston, MA 02110\\
USA
#+end_textbox

[fn:2]

#+ATTR_ODT: :style "OrgTextBoxFrameFlushRight"
#+begin_textbox
The Linux Foundation\\
548 Market St\\
PMB 57274\\
San Francisco, California\\
94104-5401 US
#+end_textbox

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="OrgTextBoxFrameFlushRight"
             style:parent-style-name="OrgTextBoxFrame"
             style:family="graphic">
  <style:graphic-properties fo:border="none"
                            fo:padding="0.15cm"
                            style:horizontal-pos="right"
                            style:horizontal-rel="paragraph-content"
                            style:vertical-pos="top"
                            style:vertical-rel="paragraph" />
</style:style>
<style:style style:name="OrgTextBoxFrameFlushLeft"
             style:parent-style-name="OrgTextBoxFrame"
             style:family="graphic">
  <style:graphic-properties fo:border="none"
                            fo:padding="0.15cm"
                            style:horizontal-pos="left"
                            style:horizontal-rel="paragraph-content"
                            style:vertical-pos="top"
                            style:vertical-rel="paragraph" />
</style:style>
#+end_src

Additional Note on using Textboxes
You can use textboxes to position text wherever you want.
For example, if you merely want the textboxes in the above example to be positioned right or left, and  you are OK with those textboxes  being staggered like so
A formal Indian-style letter

then do this

#+odt_preferred_output_format: pdf

#+ATTR_ODT: :style "OrgTextBoxFrameFlushRight"
#+begin_textbox
*From*

Free Software Foundation\\
51 Franklin Street, Fifth Floor\\
Boston, MA 02110\\
USA
#+end_textbox

#+ATTR_ODT: :style "OrgTextBoxFrameFlushLeft"
#+begin_textbox
*To*

The Linux Foundation\\
548 Market St\\
PMB 57274\\
San Francisco, California\\
94104-5401 US
#+end_textbox

Pariatur quis est,

Voluptate sit ex irure sed adipiscing ad sed in proident. Cillum nisi
adipiscing dolore et aliqua cupidatat veniam, quis ut pariatur magna
laborum.  Minim consequat proident, excepteur consectetur elit,
nostrud sunt exercitation.  Laborum velit est laborum ipsum sit elit,
ex ipsum ipsum sint eiusmod cupidatat minim id anim laboris fugiat.
Aliquip qui labore ad incididunt deserunt sunt enim.

#+begin_center
Thanking You,
#+end_center

#+ATTR_ODT: :style "OrgTextBoxFrameFlushRight"
#+begin_textbox
Yours Sincerely,\\
Whitetrillium
#+end_textbox

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="OrgTextBoxFrameFlushRight"
             style:parent-style-name="OrgTextBoxFrame"
             style:family="graphic">
  <style:graphic-properties fo:border="none"
                            fo:padding="0.15cm"
                            style:horizontal-pos="right"
                            style:horizontal-rel="paragraph-content"
                            style:vertical-pos="top"
                            style:vertical-rel="paragraph" />
</style:style>
<style:style style:name="OrgTextBoxFrameFlushLeft"
             style:parent-style-name="OrgTextBoxFrame"
             style:family="graphic">
  <style:graphic-properties fo:border="none"
                            fo:padding="0.15cm"
                            style:horizontal-pos="left"
                            style:horizontal-rel="paragraph-content"
                            style:vertical-pos="top"
                            style:vertical-rel="paragraph" />
</style:style>
#+end_src


text:
Leading * breaks code
I don't know if the presence of a leading * was meant to be in the code or if it's just a typo, but still I didn't expect it would break the code as if interpreted as a headline. Has dis been documented somewhere?
** DONE Programming - Python
  [2022-06-26 Sun]

#+BEGIN_SRC sh
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8          2         auto mode
1            /usr/bin/python3.8          2         manual mode
2            /usr/local/bin/python3.10   1         manual mode

Press <enter> to keep the current choice[*], or type selection number:
#+END_SRC

Yeah it breaks... Not sure its intended/bug/... But I got it working by inserting a zero width space before the '*' ie Do C-x 8 RET ZERO WIDTH SPACE with point at *, which may cause other problems correctable by part of an answer to my recent question https://emacs.stackexchange.com/a/72520/5223 -- See my comments

ANother simpler option is just  indent the whole src block with a space

The more idiomatic way to represent a combination of shell code and the output of that code in orgmode is to do something like this:
#+BEGIN_SRC sh :results verbatim
sudo update-alternatives --config python3
#+END_SRC

#+RESULTS:
: There are 2 choices for the alternative python3 (providing /usr/bin/python3).
:
: Selection    Path                       Priority   Status
: ------------------------------------------------------------
: * 0            /usr/bin/python3.8          2         auto mode
: 1            /usr/bin/python3.8          2         manual mode
: 2            /usr/local/bin/python3.10   1         manual mode
:
: Press <enter> to keep the current choice[*], or type selection number:

With this formatting, you can execute the code block to automatically generate the output. Or, if you prefer to manually enter the output, you can just prefix each line with the : symbol, and omit the #+RESULTS: header.

"you can execute the code block to automatically generate the output." How so?

With point in the source block, C-c C-c. There may be some configuration needed: https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks

The  best way to create a block, is

C-c C-,, choose s (or whatever) and choose bash (or whatever)
It will create en empty block like so.

#+begin_src sh
#+end_src

Put your cursor within that block and do C-c '. In the resulting buffer, copy the code, indent if needed, and press C-c C-c.

You will get a block like this

#+begin_src sh
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

Selection    Path                       Priority   Status
------------------------------------------------------------
,* 0            /usr/bin/python3.8          2         auto mode
1            /usr/bin/python3.8          2         manual mode
2            /usr/local/bin/python3.10   1         manual mode

Press <enter> to keep the current choice[*], or type selection number:
#+end_src

Note the , before *.  Indenting the block wouldn't work because org will think that the * is a bullet point.

Btw, what you have within your sh block is not all shell script.  It is a combination of shell command, its output, and all manner of things. So, use some other block.

What is the long form of C-c '? For me, undefined.

Are you doing it from an Org mode buffer? It should be bound to org-edit-special.


text:
calc: fill multiple adjacent rows with a formula?
With Table>Set Field>Formula, I'm able to do what I want for a particular field, in this case that corresponding to Aug 07. How can I fill multiple adjacent fields in one go, say Aug 7-15?
#+TITLE: Ledger
#+CONSTANT: r=10

| Date                 | Owed |
|----------------------+------|
| [2022-08-06 Sat]     |   10 |
| [2022-08-06 Sat] + d |   20 |
#+TBLFM: @3$1=@2$1+1d::@3$2=@2$2+10

The following table/formula should do what you want IIUC:
| Date             | Owed |
|------------------+------|
| [2022-08-06 Sat] |   10 |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
|                  |      |
#+TBLFM: @3$1..@>$1=@-1$1+1::@3$2..@>$2=@-1$2+10

You need to have enough rows for what you want: the formula will fill however many you actually have.
The formula reads: row 3 to the last row, column 1: use the date from the entry above the current row and the first column(@-1$1), and add one day to it. The second part is similar but it adds 10 to the entry from the previous row and the second column.
Note that I did not use the d: calc then calculates dates properly.
You might also find S-RET useful when filling in tables with dates: you get the first date in and then keep pressing S-RET for each next day, however many times you wish.
Relevant sections of the manual:
References - see particularly the Range references subsection.
Field references in the same section as above but in the Field references subsection describes relative references like @-1.
Built-in Table Editor - see the Calculations subsection for S-RET.
EDIT: There are two formulas on the #+TBLFM: line: the first one, @3$1..@>$1=@-1$1+1, fills in the first column as indicated by its range: third to last row, first column; the second, @3$2..@>$2=@-1$2+10, fills in the second column: its range is third to last row, second column. You can also write formulas for rectangular ranges consisting of multiple rows and columns, e.g. @2$1..@>$> = 0 would initialize a table to 0 (we leave the first row alone, assuming it contains headers).
To evaluate the formulas, just C-c C-c on the #+TBLFM: line.
Note that in order for the formula to work the way you want, you must have enough empty rows for your criteria (e.g. to fill in from Aug 6 to Aug 15, you must have 10 rows in the body of the table), but instead of counting, I prefer to create the table with more rows than necessary and trim off the excess after the formula has been applied.
If you want a hybrid approach where you use S-RET for the first column to manually create it and then use a formula for the second column, just keep the second formula in the #TBLFM: line:
| Date             | Owed |
|------------------+------|
| [2022-08-06 Sat] |   10 |
| [2022-08-07 Sun] |      |
| [2022-08-08 Mon] |      |
| [2022-08-09 Tue] |      |
| [2022-08-10 Wed] |      |
| [2022-08-11 Thu] |      |
| [2022-08-12 Fri] |      |
| [2022-08-13 Sat] |      |
| [2022-08-14 Sun] |      |
| [2022-08-15 Mon] |      |
#+TBLFM: @3$2..@>$2=@-1$2+10

C-c C-c on the #+TBLFM: line will leave the first column untouched and fill in the second column.

If I do S-RET under Owed in the second row, I get $11 instead of $20...

That' correct: the default increment is 1. That works well with the dates (if you want to increment by days), but it doesn't work with other increments. You can set the value of org-table-copy-increment to 10 before you do the second column, but it's easier to use the formula. But I often set it to 7 before doing S-RET on a dates column, if I want to increment by weeks, rather than by days. Note that in a non-numeric, non-date column, S-RET copies down the previous entry, so it's a quick way to fill in a text column where the entries are constant for longish stretches.

The formula you created is supposed to increment rows in the second column by $10, right? How do I fill the rows using this formula?

Edited the answer to add some more info: HTH.


text:
Typing "eats" text on the right
Sometimes key binding changes unexpectedly such that if I position the cursor next to the first occurence of 'm'
lorem ipsum

and type 'xxxx', I get
loremxxxxum

instead of:
loremxxxx ipsum

Also, typing backspace replaced each character by a blank rather than deleting it.
If I quit and re-open the fame file, backspace works as expected. What causes this problem and how to fix it during an Emacs session?
This is using GNU Emacs 26.3 (GUI)

You've accidentally turn on overwrite-mode, probably by accidentally hitting the <insert> key (typically labeled Insert on your keyboard).
When overwrite-mode is enabled, text you type replaces existing text.
As for how to "fix it": just hit the <insert> key again: it's a toggle key.
(As @db48x mentioned in his answer, you can turn on view-lossage to see which keys and mouse actions you've recently used. That will no doubt show you that you used key <insert>.)

If you don't know what the <insert> key is, toggle M-x overwrite-mode (man 5.21).

You can use M-x view-lossage to review the last few hundred keystrokes.

If you know that you never want overwrite-mode, you can put this in your init file:
(put 'overwrite-mode 'disabled t)


text:
Is there a reliable way read an existing event, if any, and remove it from the queue with zero delay?
An answer to another question suggests that supplying a timeout of 0.0 to read-event (as the
optional SECONDS parameter) will always return nil immediately, and, if I'm reading the code in
Emacs' keyboard.c correctly, even a (very) very small non-zero timeout could return nil without
checking everywhere for an existing event.
Because input-pending-p can return false positives, calling read-event with a non-zero value for
SECONDS to try to get that (nonexistant event) could cause a delay and still return nil.
Practically, it seems like using a millisecond or two for SECONDS should be fine, but it does feel
less tidy than if read-event returned any available events even with a timout of 0.0.
Short of a locall Emacs build, is there a solution a particularly particular user might prefer?
The code @phils gave with his answer demonstrates this is not correct if "unread" events are
available in any of 3 queues. I've added code that suggests yet another event-queue is checked by
input-pending-p that is skipped by read-event when SECONDS is 0.0.
My polling loop below is more complicated than I'd like, but I wanted to record all the relative
event times. The quit key (C-g) will terminate.
The code starts calling read-event with a SECONDS value of 0.0, increasing it after 5 seconds.
It records when input-pending-p first returns true, and then the time and SECONDS value when
read-event first returns non-nil.
For me, pressing a key before 5 seconds is up demonstrates that input-pending-p can be true, but
until SECONDS is increased to at least a little above 0.0, read-event consistently returns
nil.
(let* ((input-at) (read-at) (wait-to-try 0.0) (deadline (+ (float-time) 5.0)) (past-due))
  (while 't
    (setq past-due (- (float-time) deadline))
    (when (and (not input-at) (input-pending-p)) (setq input-at past-due))
    (when (not read-at)
      (when (> past-due 0.0) (setq wait-to-try (* 0.001 past-due)))
      (when (read-event nil nil wait-to-try) (setq read-at past-due)))
    (message "past: %f  in-p: %s  in-at: %s  wait: %s  read-at %s"
      past-due (input-pending-p) input-at wait-to-try read-at)
    (redisplay)))

I suppose you could use (or (read-event nil nil 0) (and (input-pending-p) (read-event nil nil 0.1)))?  Or maybe just the and form.  But I guess that's what you were playing with to begin with, when discussing the possibility of false-positives incurring the full delay.  Hopefully someone with more knowledge than me will chip in.

Edit: With the new information and test case provided in the question, it's clear that this answer is incorrect (or at least inadequate).  Clearly there are indeed additional input event queue(s) which do not get the opportunity to feed event-read while elisp is being actively executed, until some kind of waiting occurs.
Original answer follows...

If the event is already existing/pending, I don't think you need to deal with timeouts at all?
(let ((unread-command-events '(42)))
  (read-event))
=> 42

An answer to another question suggests that supplying a timeout of zero to read-event (as the optional SECONDS parameter) will always return nil immediately

That's certainly not what I'm seeing in a cursory test:
(let ((unread-command-events '(1))
      (unread-input-method-events '(2))
      (unread-post-input-method-events '(3)))
  (list (read-event nil nil 0)
        (read-event nil nil 0)
        (read-event nil nil 0)))

=> (3 1 2)

Do events normally flow to unread-command-events ? From the docs I thought this was a sort of "pushback stack", and events would only go on that list if a function read it from the standard queue, then decided it didn't want it.

Beyond the fact that there are at least three different "unread events" lists, I'm not certain of the details; but I would have expected the result to be the same regardless -- if there's an event waiting in a queue and you call read-event I would expect the waiting event to be returned in all cases.

Yeah, that's what I expect, but I don't think it's the case. I ended up rewriting what I was doing to use a timer instead and add a little dynamics into the mix anyway, but I'd still like to understand...

If you can provide an example of it working differently, that would no doubt help.

Ah! I missed your test after reading your earlier comment. Awesome! I’ll cook something up. Thanks!

Nice one.  With some extra messaging I can see that the three unread event lists I mentioned seem to remain empty while a key press within that first 5 seconds is pending, so it looks like your original understanding is correct -- such events are waiting in some other event queue which cannot be processed while other elisp is being actively executed.

I suspect keyboard.c is the code to read if you really want to get into the details (input-pending-p takes us to get_input_pending, at which point things immediately get low-level, and entirely outside of my area of knowledge).

Thanks - I appreciate the feedback and investigations!


text:
Importing text with hyperlinks
I have a file in (say) odt format that contains hyperlinks, like this, and I want to edit the content of this file using emacs-org. I can't just copy paste the content from *odt to *org, the links don't persist. What, then?
PS: there is a post whose title seems to match my question, but the answer does not.

I would use pandoc to convert the document from odt to org, and then I'd edit the newly created org document.
pandoc -r odt -w org example.odt > example.org
emacs example.org       # or
emacsclient example.org # if you have server-mode setup


text:
python language server with eglot - can't get it working
emacs version: 28.2
eglot version: 20221020.1010
After successfully using eglot with eglot-jl for some time when programming in julia, I now have to use python for a few small tasks, and I was looking to replicate the workflow.
After reading around, I tried many different things but I cannot get this working with use-package. I want to use the pyright language server, but I cannot see how to configure it for that - everywhere I read where people say they are configuring for that purpose, they just leave it as is, which led me to assume it's the default eglot config, but I checked eglot-server-programs and it listed some byte compiled stuff (which I assume can be a version of pyright).
Additionally, I am also confused with the package names "python" for the in-built python mode and "python-mode" from melpa, as there seems to be naming conflicts at play here.
For reference, here's my configuration for julia:
  (use-package julia-mode
    :mode "\\.jl\\'"
    :interpreter ("julia" . julia-mode)
    :init
    (setenv "JULIA_NUM_THREADS" "4")
    :config
    (add-hook 'julia-mode-hook 'company-mode)
    (add-hook 'julia-mode-hook #'yas-minor-mode)
    (add-hook 'julia-mode-hook 'julia-repl-mode)
    (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm)))
    (add-hook 'julia-mode-hook 'eglot-jl-init)
    (add-hook 'julia-mode-hook 'eglot-ensure)
    (add-hook 'julia-mode-hook (lambda () (setq eglot-connect-timeout 120)))
    (add-hook 'julia-mode-hook (lambda () (setq eglot-autoshutdown t)))
    )

I've tried both leaving it unconfigured (and running M-x eglot manually) as it's supposed to work out of the box and the following:
  (use-package python
    :config
    (add-hook 'python-hook (lambda ()
                                  (setq
                                   python-indent-guess-indent-offset-verbose
                                   nil)
                                  )
              )
    (add-hook 'python-mode-hook 'company-mode)
    (add-hook 'python-mode-hook #'yas-minor-mode)
    (add-hook 'python-mode-hook 'eglot-ensure)
    (add-hook 'python-mode-hook (lambda () (setq eglot-connect-timeout 120)))
    (add-hook 'python-mode-hook (lambda () (setq eglot-autoshutdown t)))
    )

Both land me "[eglot] Sorry, couldn't guess for `python-mode'! Enter program to execute (or :):"
Do I actually need to install the pyright server by myself? Not even the pyright repository readme seems to imply this.

After I specified the interpreter with
:interpreter ("python3" . python-mode)

and manually installed pyright with
pip install pyright

it worked.


text:
How to repeat the last yank command N times?
I'm just not able able to replicate the answer on this. Starting with:
lipsum

I do (my interpretaton):

Alt-W over the word (copy)
Enter (new line)
Ctrl-Y (paste)
Alt-2 Ctrl-X z (repeat last two commands)

What I expected:
lipsum
lipsum
lipsum

What I get:
lipsum
lipsumlipsum

How did I do wrong?
PS1: breakdown of 1.

C-SPC before lipsum
C-E
M-W

Effect: selected region=lipsum(cursor at end of line).

You copied only a word, not that word plus the newline character that follows it.
You then yanked the copied word twice. The yanked words aren't separated by newline chars because you didn't include such a char in what you copied to the kill-ring.

C-SPC before the word you want to copy.

Then C-n to move down a line (to the beginning of the next line).

Then M-w to copy the word and newline.

Then do your yanking (whether by repeating or not).

"You copied only a word, not that word plus the newline character that follows it." But I repeated the last two commands. The sequence C-SPC C-n does not move down a line in my case, it selects the word and positions the cursor at the end of the line.

That's probably because there is no newline at the end of the word. Insert one and then do C-SPC at the beginning of the word, then C-n to move to after the newline, then M-w.

The problem is repeat with an argument does not repeat N times. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Repeating.html and the answer I've added that shows what it actually does.

@glucas: Good point.

If you want to yank something N times, the simplest approach is probably to use a keyboard macro: See https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html.
For example, mark and copy the text, then:

F3 C-y F4 ; record a keyboard macro that does the yank
C-u 20 C-x e ; run last macro 20 times

Why didn't your approach work?
Your assumption here is incorrect:

Alt-2 Ctrl-X z (repeat last two commands)

From the doc for repeat-command:

Repeat most recently executed command. If REPEAT-ARG is non-nil (interactively, with a prefix argument),
supply a prefix argument to that command.  Otherwise, give the
command the same prefix argument it was given before, if any.

So C-x z will only repeat the last command. In your example you are calling  yank with prefix arg 2. Checking what yank does with that:

With argument N, reinsert the Nth most recent kill.

So actually you are yanking the 2nd most recent kill. Try this to see it work. Start with a buffer with this and point at the beginning:
one
two

Mark and kill one and then two (with trailing newline), e.g.

C-SPC C-n M-w ; mark, go down a line, copying one
C-SPC C-n M-w ; same again, copying two
C-y           ; yank (most recent)
M-2 C-x z     ; repeat with argument 2 (yank 2nd most recent)

And the end result is this:
one
two
two
one


text:
meaning of a red dot on border of window
This entry was created using org-capture and removing 'TODO'. I wonder why it shows a red dot in the lhs.

The red mark indicates the presence of a bookmark.  org-capture leaves this when it is done (the bookmark is called org-capture-last-stored).  See the manual for more.


text:
Template is not a valid Org entry or tree
There is a previous post for that error, but it didn't help in my case. What could be causing the error?
Set up:
$ ls -a $HOME/org
 .   ..  '#notes.org#'   .#notes.org   .notes.org   .notes.org~   tpl-todo.txt
$ cat '$HOME/.emacs'
(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.
 '(org-capture-templates
   '(("t" "TODO entry" entry
      (file+headline ".notes.org" "Get Things Done")
      "tpl-todo.txt" :empty-lines-after 1)))
 '(org-default-notes-file "$HOME/org/.notes.org")
 '(org-directory "$HOME/org")
 '(org-todo-keywords '((sequence "TODO" "DONE" "CANCEL")))
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(emacsql-mysql csv-mode gh-md emojify-logos emojify gnu-elpa org auctex)))
(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.
 )
(put 'downcase-region 'disabled nil)
$ cat $HOME/org/tpl-todo.txt
* TODO %^(description)
%? 'cursor
:LOGBOOK:
- Added: %U
:END:
$ cat $HOME/org/.notes.org
* Get Things Done

Also tried with this replacement:
'(org-capture-templates
  '(("t" "TODO entry" entry
     (file+headline "$HOME/org/.notes.org" "Get Things Done")
     "$HOME/org/tpl-todo.txt" :empty-lines-after 1)))

Instruction:
M-x org-capture
t

Message:
org-capture: Capture template ‘t’: Template is not a valid Org entry or tree

Update 1
Based on a comment, I modified the setup as follows:
(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.
 '(org-capture-templates
   '(("t" "TODO entry" entry
      (file+headline "/home/[user]/org/.notes.org" "Get Things Done")
      file "/home/[user]/org/tpl-todo.txt" :empty-lines-after 1)))
 '(org-default-notes-file "/home/[user]/org/.notes.org")
 '(org-directory "/home/[user]/org")
 '(org-todo-keywords '((sequence "TODO" "DONE" "CANCEL")))
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(emacsql-mysql csv-mode gh-md emojify-logos emojify gnu-elpa org auctex)))
(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.
 )
(put 'downcase-region 'disabled nil)

Replace $HOME with ~ in the elisp: I do not think emacs expands shell vars in strings (at least, mine doesn't).  Also, in the replacement version, it should be (file "/path/to/template") not just "/path/to/template".

@FranBurstall I did $HOME after realizing ~ wasn't working, and now I've replaced it by "/homer/[username]". And based on your comment, I've also prepend file  to  "$HOME/org/tpl-todo.txt`. I will put the whole as an update in the post.

The syntax is wrong: try '(org-capture-templates    '(("t" "TODO entry" entry       (file+headline "/home/[user]/org/.notes.org" "Get Things Done")       (file "/home/[user]/org/tpl-todo.txt") :empty-lines-after 1))) with the template file specification in parens (untested).

@NickD Now it works. Since I last posted I realized (.) missing around `file "/home/[user]/org/tpl-todo.txt", but that still didn't solve it, so there must be something else.

So what else did you change to make it work?

@NickD I pasted your solution. Perhaps I had left out a typo, or spaces matter.

OK - thanks for the clarification. I posted the comment as an answer based on your verification.

[Making the comment into an answer.]
The syntax is wrong - try this:
...
'(org-capture-templates
    '(("t" "TODO entry" entry
       (file+headline "/home/[user]/org/.notes.org" "Get Things Done")
       (file "/home/[user]/org/tpl-todo.txt") :empty-lines-after 1)))
...

with the template file specification in parens.
At the time I posted the comment, it was untested, but the OP tried it and verified that the problem is resolved.


text:
Syntax issue using `add-to-list`
This set up ignores the custom-set-variables statement and generates the warning reproduced below. If I uncomment the first statement, however, it works. This is probably a novice's issue... Is there any way to make the first statement using the interface such as to prevent syntax errors?
(add-to-list 'org-refile-targets '("~/Documents/org/.notes.org"  :maxlevel . 4))
;; (setq org-refile-targets '(("~/Documents/org/.notes.org" :maxlevel . 4)))
(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.
 '(org-agenda-files '("~/Documents/org/.notes.org"))
 '(org-babel-load-languages '((python . t) (emacs-lisp . t) (shell . t)))
 '(org-capture-templates
   '(("b" "Bookmark" entry
      (file+headline "~/Documents/org/.notes.org" "Review")
      (file "~/Documents/org/tpl-bookm.txt")
      :immediate-finish t :jump-to-captured t :empty-lines-before 1)
     ("c" "Code" entry
      (file+olp "~/Documents/org/.notes.org" "Code")
      (file "~/Documents/org/tpl-code.txt")
      :empty-lines 1)
     ("d" "Deadline" entry
      (file+headline "~/Documents/org/.notes.org" "Deadline")
      (file "~/Documents/org/tpl-deadl.txt"))
     ("j" "Journal" entry
      (file+olp+datetree "~/Documents/org/.notes.org" "Journal")
      (file "~/Documents/org/tpl-journ.txt")
      :empty-lines 1 :tree-type week)
     ("t" "Task" entry
      (file+headline "~/Documents/org/.notes.org" "Task")
      (file "~/Documents/org/tpl-task.txt")
      :empty-lines 1)))
 '(org-default-notes-file "~/Documents/org/.notes.org")
 '(org-directory "~/Documents/org")
 '(org-log-into-drawer t)
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(ob-sagemath babel emacsql-mysql csv-mode gh-md emojify-logos emojify gnu-elpa org auctex)))
(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.
 )
(put 'downcase-region 'disabled nil)

Under Warnings:

Warning (initialization): An error occurred while loading
‘/home/erwann/.emacs’:
Symbol's value as variable is void: org-refile-targets
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with the
‘--debug-init’ option to view a complete error backtrace. Disable
showing Disable logging Warning (org): Capture requirement: switching
buffer #<buffer .notes> to Org mode Disable showing Disable logging

This is probably a duplicate.

It is the first line in the code that causes the error. Your are attempting to add a value to a list before the list has been initialized. This is resulting in an error being thrown because the org-refile-targets variable is not yet defined.
To get around this, you can wrap the code in a with-eval-after-load block so that the value is added to the list after it has been initialized.
(with-eval-after-load 'org-refile
  (add-to-list 'org-refile-targets '("~/Documents/org/.notes.org"  :maxlevel . 4)))

This will ensure that the value is added to the list after the org-refile-targets variable has been initialized and defined.

@Erwann did this solve your issue? If so please accept the answer or else let me know if there is still a problem.


text:
errors related to agenda
#+startup: logdrawer
#+SEQ_TODO: URGENT(u!) TODO(t!) SOMEDAY(s!) | DONE(d@) CANCEL(c@)

* Task

** TODO Pay bill
DEADLINE: <2023-02-20 Mon>
:LOGBOOK:
- State "TODO"       from              [2023-01-25 Wed 22:57]
:END:

If I position the cursor on the deadline's date and do M-x org-open-at-point, I get this error:
Debugger entered--Lisp error: (void-variable org-agenda-buffer-name)
  org-follow-timestamp-link()
  org-open-at-point(nil)
  funcall-interactively(org-open-at-point nil)
  call-interactively(org-open-at-point record nil)
  command-execute(org-open-at-point record)
  execute-extended-command(nil "org-open-at-point" "org-open-at-point")
  funcall-interactively(execute-extended-command nil "org-open-at-point" "org-open-at-point")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

If I do M-x org-agenda-month-view, I get this error:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  calendar-gregorian-from-absolute(nil)
  org-agenda-compute-starting-span(nil month nil)
  org-agenda-change-time-span(month nil)
  org-agenda-month-view(nil)
  funcall-interactively(org-agenda-month-view nil)
  call-interactively(org-agenda-month-view record nil)
  command-execute(org-agenda-month-view record)
  execute-extended-command(nil "org-agenda-month-view" "org-agenda-month")
  funcall-interactively(execute-extended-command nil "org-agenda-month-view" "org-agenda-month")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

How to intepret these errors?

AFAICS, the only reason for org-agenda-buffer-name to be undefined (i.e. a void variable) is that org-agenda is not loaded.  Do M-: (featurep 'org-agenda) to check if the feature has been enabled. If not, M-x load-library RET org-agenda. But you should fix your init file to initialize Org mode properly.

Starting from emacs -Q, I cannot reproduce the second problem. If org-agenda is not loaded, then Emacs complains that org-agenda-month-view is undefined. If it is loaded, then the command does not raise an error: it just reports No Org agenda currently displayed.

@NickD " But you should fix your init file to initialize Org mode properly. " In this case, this means what?

It means that you should not have to explicitly load org-agenda: it's hard to be specific without knowing how you install/initialize Org mode, but ideally, you should have all the functions that you need available without having to load anything explicitly. In my case, e.g., my init file contains (require 'org-loaddefs) which is an auto-generated file that contains autoload definitions for everything. There is unfortunately no such facility for variables AFAIK, so this is not a complete solution, but it goes a long way towards solving such problems.

This is actually a bug: see https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c45a05892 for the fix.

@NickD " it's hard to be specific without knowing how you install/initialize"→https://emacs.stackexchange.com/q/75542/19777

I didn't look at it in detail, but other than "the definition has to precede the use" problem that the answer on that question identifies (which is a correct answer IMO), there is not much else going on there: just settings of options. In any case, as I mentioned above, this problem is not because of you doing something wrong (so my comment above about fixing your init file was off the mark): it is a bug In Org mode. The workaround I suggested (loading org-agenda) will carry you through until you can update your Org mode to pick up the fix.


text:
no org-babel-execute function for sh!
If do M-x org-babel-execute-src-block over the code block below, I get "evaluate this bash code block on your system", and then "no org-babel-execute function for bash". Changing bash to shell or sh, same. I found support for powershell but not the ones listed. The comment in this post mentions org-babel-do-load-languages, but I don't have it. So what then, could I do? Also, why isn't there a key binding for the first command listed?
#+begin_src bash :results output
echo "Hello world!"
#+end_src

M-x load-library RET ob-shell RET should allow you to execute the src block. Assuming that works, then add  (eval-after-load 'org (add-to-list 'org-babel-load-languages '(shell . t))) to your init file to make it permanent - or customize org-babel-load-languages through the customize interface.

There should be: it is defined in org.el so do (require 'org) and then try C-h v org-babel-load-languages again. With the eval-after-load form in your init file, you don't have to worry about when org is loaded: when it is, org-babel-load-languages will be defined and the form will reset it to add the ob-shell backend.

Based on the comments, do M-x customize-variable RET org-babel-load-languages, and proceed as intuitable from the picture. Then go back to the original buffer and reload the emacs init file. Then do M-x org-babel-execute-src-block (or C-c C-c) over the code block.
#+begin_src shell :results output
echo "Hello world!"
#+end_src

Results in this addition to the buffer:
#+RESULTS:
: Hello world!


text:
Automatic table layout
Here's a hypothetical table that keep tracks of cloud content.
+-----------------------------+----------+-------------------+
| file | server | uname |
+-----------------------------+----------+-------------------+
| file1          | google    | uname1                      |
| file2 | mega | uname2 |
| file3            | dropbox     |   uname3                   |
+-----------------------------+----------+-------------------+

Is there a command to make | align with the respective +?
Better yet, is it possible to automatically set the + to accommodation the largest entry in the corresponding column?

a) I tried org-table-align on each row, and it did not work.
UPDATE:
I've realize that a) meets the requirement 2. So that leaves 1.

Use orgtbl-mode, unless you are in an org-mode file in which case the tables should just work automatically. If that’s not suitable, then please expand your question to include more relevant information.
Edit: If you’re in an org file, the table syntax that it expects looks like this:
|-------+---------+--------|
| file  | server  | uname  |
|-------+---------+--------|
| file1 | google  | uname1 |
| file2 | mega    | uname2 |
| file3 | dropbox | uname3 |
|-------+---------+--------|

Note that every line, including the rules, starts with a | character.
Pressing tab will reflow the table to make the columns line up, and move you to the next cell. Hitting enter does the same but then moves you down to the next row.

M-x org-table-align is invokable, just doesn't do the job. I started from an empty *org  file to make sure something else wasn't corrupting it. Should the cursor be positioned somewhere in particular?

You are showing a table.el table in your question. If you want an Org mode table, you should enter it the way @db48x shows in the answer: | at the beginning and end of each row and in-between columns; I would worry about the contents of the table, not the "rules" (hlines or whatever you want to call them) - you can add those later (e.g. with org-table-insert-hline, although I tend to just open an empy line and type |-TAB).


text:
How to autocomplete a property?
I've replicated org mode's example, except I didn't manually fill out the value for key Publisher under Goldberg Variations. How do I get a prompt for autocompletion?
* CD collection
  :PROPERTIES:
  :NDisks_ALL:  1 2 3 4
  :Publisher_ALL: "Deutsche Grammophon" Philips EMI
  :END:
** Classic
*** Goldberg Variations
    :PROPERTIES:
    :Title:     Goldberg Variations
    :Composer:  J.S. Bach
    :Artist:    Glenn Gould
    :Publisher:
    :NDisks:    1
    :END:

C-c C-x p on the Publisher property, RET to confirm the property name (it's already defaulted to Publisher), TAB to get completions on the property value. I'm given the three choices from Publisher_ALL.

From the comments: C-c C-x p on the Publisher property.


text:
Mo refile targets
I have the following setup:
(custom-set-variables
 '(org-refile-targets
   '(("~/Documents/org/x.org, ~/Documents/org/y.org" :maxlevel . 5))))

I open x.org and position the cursor on a subtree, do M-x org-refile-copy, I get: "No refile targets". What could be the reason?

Did you see the answer? Did you ever get this to work?

C-h v org-refile-targets says:
Targets for refiling entries with ‘M-x org-refile’.
This is a list of cons cells.  Each cell contains:
- a specification of the files to be considered, either a list of files,
  or a symbol whose function or variable value will be used to retrieve
  a file name or a list of file names.  If you use ‘org-agenda-files’ for
  that, all agenda files will be scanned for targets.  Nil means consider
  headings in the current buffer.
- ...

So the specification of the "files to be considered" is a list of files in this case. In Lisp, a list has the form (a b c) (see e.g. List Processing in the Intro manual or Cons Cell and List Types in the Elisp reference manual). In this case, you have two files (represented as strings), so a list of those files is
("~/Documents/org/x.org" "~/Documents/org/y.org)

Putting that into the custom-set-variables gives you:
(custom-set-variables
 '(org-refile-targets
   '((("~/Documents/org/x.org" "~/Documents/org/y.org") :maxlevel . 5))))

N.B. No commas to separate the elements of the list. Each element is a string, so it has to be surrounded by double quotes - see Strings in the Elisp intro manual and Strings in the Elisp reference manual.


text:
Extending calendar's compatible range
org-time-stamp-inactive RET 1969-05-02 inserts [1970-05-02 Sat] in the active buffer,
and generates this message: "year was forced into compatible range (1970-2037)". Thus this question: can the range be extended?

Have a look at the doc-string for the variable org-read-date-force-compatible-dates, and try the recommended steps to test your system compatibility.  If your system is compatible with a broader range of dates, then consider customizing this variable to a nil value.
org-read-date-force-compatible-dates is a variable defined in org.el.
Its value is t

Should date/time prompt force dates that are guaranteed to work in Emacs?

Depending on the system Emacs is running on, certain dates cannot
be represented with the type used internally to represent time.
Dates between 1970-1-1 and 2038-1-1 can always be represented
correctly.  Some systems allow for earlier dates, some for later,
some for both.  One way to find out is to insert any date into an
Org buffer, putting the cursor on the year and hitting S-up and
S-down to test the range.

When this variable is set to t, the date/time prompt will not let
you specify dates outside the 1970-2037 range, so it is certain that
these dates will work in whatever version of Emacs you are
running, and also that you can move a file from one Emacs implementation
to another.  Whenever Org is forcing the year for you, it will display
a message and beep.

When this variable is nil, Org will check if the date is
representable in the specific Emacs implementation you are using.
If not, it will force a year, usually the current year, and beep
to remind you.  Currently this setting is not recommended because
the likelihood that you will open your Org files in an Emacs that
has limited date range is not negligible.

A workaround for this problem is to use diary sexp dates for time
stamps outside of this range.

  This variable was introduced, or its default value was changed, in
  version 24.1 of Emacs.
  You can customize this variable.

The earliest date I can get with this is <0100-01-01 Fri>.


text:
How to toggle binary / reader
M-x TeX-view opens the binary of the generated pdf. I'm looking for the output. I used to know how to toggle between the two but I forgot. What is it?

Not sure what TeX-View has to do with this: I presume it just opens the PDF file and since you've tagged your question with pdf-tools, I presume it should open it using that.
The fact that it opens it literally probably means that there is no entry in auto-mode-alist to tell it what mode the file is in, so it opens it in Fundamental mode.
Check that there is an entry in auto-mode-alist that looks like this:  ("\\.[pP][dD][fF]\\'" . pdf-view-mode).
AFAICT, in pdf-view-mode you can type C-c C-x to switch to  hexl-mode and type C-c C-x again to switch back to pdf-view-mode. But that's probably not going to work in Fundamental mode.


text:
How to evaluate call a function defined in a code block?
I expected 'lorem ipsum' for the code below. What am I doing wrong?
#+NAME: foo
#+BEGIN_SRC emacs-lisp
  (defun foo () (insert "lorem ipsum"))
#+END_SRC

;; C-c C-c
#+CALL: foo()

#+RESULTS:
: foo

UPDATE
Based on the answer I did this:
#+NAME: foo
#+BEGIN_SRC elisp
  (defun foo () "lorem ipsum")
#+END_SRC

#+name: bar
#+begin_src elisp
(foo)
#+end_src

;; C-c C-c
#+CALL: bar()

And I'm getting this message: "Symbol's function definition is void".

Just try the right thing you want to achieve: (foo)

@Claudio I see what you mean: (foo) C-x C-e

Try this:
#+NAME: foo
#+BEGIN_SRC emacs-lisp :results silent
  (defun foo () (insert "lorem ipsum"))
#+END_SRC

#+RESULTS: foo

#+name: bar
#+begin_src elisp
(foo)
#+end_src

;; C-c C-c
#+CALL: bar()

IOW, the foo code block when executed just defines the function, it does not call it. The bar code block however calls the function that was defined by the first code block. Typing C-c C-c on the #+CALL: bar() line runs the bar code block, which runs the function, which inserts the text (and depending on where you type C-c C-c, you'll get the text inserted in somewhat unexpected places).
EDIT: The function foo inserts the text in the buffer and returns nil (that's what the last form in its body i.e. (insert "...") returns). So you get the text inserted in the buffer (and depending on where you type C-c C-c, you'll get it inserted in various places on the #+CALL: bar line). Meanwhile the #+RESULTS will contain what the function returned, i.e. nil (it is suppressed in the "normal" output of a code block but you can see it if e.g. you specify :results drawer).
If you want the function to return the text (rather than insert it in the buffer), then write the function like this:
(defun foo () "lorem ipsum")

This returns the string as its value and that is then put in the #+RESULTS block (as long as :results value is in effect, which it is by default in elisp code blocks). Plus you don't get the text inserted in more or less arbitrary places in the buffer.
EDIT 2: In answer to some additional questions/comments by the OP, the foo code block has to be evaluated first: it defines the function foo that is used by the bar code block. You always have to define something before you can use it.
Adding a :results silent header argument to the foo code block makes sure that any results output is suppressed. The code block is still evaluated: any output is thrown away. Make sure that you spell it correctly: the header argument is :results with no space between the colon and the word. See Using header aruments in the Org mode manual.

I'm getting lorem ipsum followed by #+RESULTS:. Shouldn't it be the other way around?

The function inserts the text in the buffer at whatever place you were when you pressed C-c C-c, but the function returns nil (which is what the insert call returns). If you want the function to return the string (rather than insert it in the buffer), then see my edit.

I updated my post based on your edit.

You need to define the function foo by pressing C-c C-c on the foo code block. Only after it is defined, can it be called.

Pressing C-c C-c on the foo code block inserts #+RESULTS: foo : foo. I was hoping elisp : results silent would prevents that, but it does not. Any suggestion, please?

Yes, use :results silent with no space between the colon and results.

How would I make the code block for bar silent without impeding the call to it (it does if I do :results silent)?

Please no questions  in the comments. I've made a couple of exceptions already, but this is the last one: :results silent suppresses the output; it does not inhibit the evaluation.  If you have an additional question, ask a new question.