text:
Customizing org-latex-title-command to edit title page
I would like to know how to go about editing and understanding org-latex-title-command. So far it is set to \maketitle but the documentation just has this:
   The command used to insert the title just after \begin{document}. Hide

   This format string may contain these elements:

     %a for AUTHOR keyword
     %t for TITLE keyword
     %s for SUBTITLE keyword
     %k for KEYWORDS line
     %d for DESCRIPTION line
     %c for CREATOR line
     %l for Language keyword
     %L for capitalized language keyword
     %D for DATE keyword

   If you need to use a "%" character, you need to escape it
   like that: "%%".

What would I need to do so that I can at least make my \title font, defined in org keyword #+TITLE:, bigger than its current default settings. For example, this latex wiki has as its first example:
\documentclass{article}% use option titlepage to get the title on a page of its own.
\usepackage{blindtext}
\title{The Triangulation of Titling Data in Non-Linear Gaussian Fashion via $\rho$ Series\thanks{No procrastination}}
\date{2017\\ December}
\author{John Doe\\ Magic Department\thanks{I am no longer a member of this department}, Richard Miles University
\and Richard Row, \LaTeX\ Academy}
\begin{document}
\maketitle
\section{Introduction}
\blindtext
\end{document}

I understand that org-latex-title-command will be inserted right after\begin{document}, but how do I edit this variable with its format string elements? I know that +TITLE: mytitle inserts \title{mytitle} and that \maketitle makes the title appear in the latex document. However, the latex wiki formats the title before it calls \maketitle. Then, how should I accomplish what is in the example by accessing the org-latex-title-command? Ideally, I would just like to make the title bigger without affecting org-latex-title-command. Examples would help.

your example from the latex wiki uses the default title font size: it's bigger than body text, but it hasn't been modified from the usual title size. That should be what you see in a pdf generated from an org file without needing any further customization. If the title from your org-mode file is not already in a large font, something strange is happening.

Could this be related to pdflatex? I installed MacTex.

That seems unlikely. Is the title produced in the pdf output from the org-mode source not in a large font by default on your system?

The goal of adjusting the title font size would likely more easily be addressed by using the titling package. Example: #+LaTeX_HEADER: \usepackage{titling} \pretitle{\begin{flushleft}\LARGE\sffamily}

The LaTeX command \maketitle simply formats the various title page elements (author, title, etc.) according to the current document style.  When you wrote “However, the latex wiki formats the title before it calls \maketitle,” you are misunderstanding the LaTeX code.  The \title command simply stores the text of the title; the \author command stores the author string; and so on.  They are not rendered until \maketitle is invoked.
It's generally considered bad form to override the document style's formatting, but if you want to do it anyhow and make your own custom title page, you can use any sequence of LaTeX commands instead of \maketitle.  In org-mode, that would look something like this:

#+TITLE: Monty Python \\
#+TITLE: and the \\
#+TITLE: Holy Grail
#+AUTHOR: Knott A. M\o\o se
#+DATE: 932 A.D.

#+begin_src emacs-lisp :exports results :results none :eval export
  (make-variable-buffer-local 'org-latex-title-command)
  (setq org-latex-title-command (concat
     "\\begin{titlepage}\n"
     "\\centering\n"
     "{\\LARGE %t \\par }\n"
     "\\vspace 2cm\n"
     "{\\normalsize %a \\par}\n"
     "\\vspace 3cm\n"
     "{\\huge %D \\par}\n"
     "\\end{titlepage}\n"))
#+end_src

When you export the Org document to LaTeX, you'll get a document with the following sequence inserted where \maketitle would have been:
\begin{titlepage}
\centering
{\LARGE Monty Python \\
and the \\
Holy Grail \par }
\vspace 2cm
{\normalsize Knott A. M\o\o se \par}
\vspace 3cm
{\huge (932 A.D.) \par}
\end{titlepage}

I accepted your question because it does produce similar output. However, which org version do you use? On the date section I get this line {\huge ((latex-fragment (:value \today :begin 1 :end 7 :post-blank 0 :parent #0))) \par} and the pdf does not render as expected. My org-version: 9.1.9

Huh, fascinating!  My org-version is 9.0.9.  I don't see anything on the Org mode release notes page that is obviously related.  Hmm... were you exporting to Texinfo perhaps?  --- In any case, I hope my answer gave you some additional context to learn from.

Your answer is very helpful. Since this is not a priority I will take a look later. I rather not override the org global variable.

Okay, cool.  Glad to help!  By the way, the weird way I showed you (above) to set the variable--- in a source block--- is a way to set the variable just for the current file, not globally.  (The make-variable-buffer-local accomplishes that.  It could also be done with file-local variables.)  So that might ease your mind a bit.  Cheers!


text:
How to open an IRC session using SASL?
I would like to exchange on Freenode using ERC, however I do not know how to authenticate with SASL as required.
-xxxxxx.freenode.net- *** Lookup up your hostname...
-xxxxxx.freenode.net- *** Checking Ident
-xxxxxx.freenode.net- *** Found your hostname
-xxxxxx.freenode.net- *** No Ident response
-xxxxxx.freenode.net- *** Notice -- You need to identify via SASL to use
            this server

==> ERROR from irc.freenode.net: Closing Link:
xxxxxxxxxxxxxxxxxxxx.xx     (SASL access only)

Connection failed!  Not re-establishing connection.

*** ERC terminated: connection broken by remote peer

I looked quickly the ERC manual and the EmacsWiki website. I also noticed that Emacs has a SASL library. Moreover, a developer was proposing a SASL extension for ERC on a GitHub repository.
I am looking for a solution as well as an explanation (or overview) to facilitate a possible inspection of the source code. Eventually, you can specify how to proceed for other IRC clients (rcirc,...).

I ended up patching the erc-login function to use the SASL extension. I first installed this package https://github.com/joseph-gay/erc-sasl and added this to my init file:
(require 'erc-sasl)
(add-to-list 'erc-sasl-server-regexp-list "irc\\.freenode\\.net")

(defun erc-login ()
  "Perform user authentication at the IRC server. (PATCHED)"
  (erc-log (format "login: nick: %s, user: %s %s %s :%s"
           (erc-current-nick)
           (user-login-name)
           (or erc-system-name (system-name))
           erc-session-server
           erc-session-user-full-name))
  (if erc-session-password
      (erc-server-send (format "PASS %s" erc-session-password))
    (message "Logging in without password"))
  (when (and (featurep 'erc-sasl) (erc-sasl-use-sasl-p))
    (erc-server-send "CAP REQ :sasl"))
  (erc-server-send (format "NICK %s" (erc-current-nick)))
  (erc-server-send
   (format "USER %s %s %s :%s"
       ;; hacked - S.B.
       (if erc-anonymous-login erc-email-userid (user-login-name))
       "0" "*"
       erc-session-user-full-name))
  (erc-update-mode-line))

Jon2x answer didn't work for me. However, following ERC documentation: https://elpa.gnu.org/packages/doc/erc.html#SASL

User Option: erc-sasl-mechanism
The name of an SASL subprotocol type as a lowercase symbol. The value can be one of the following:

plain and scram (“password-based”) Here, “password” refers to your
account password, which is usually your ‘NickServ’ password. To make
this work, customize erc-sasl-user and erc-sasl-password or specify
the :user and :password keyword arguments when invoking erc-tls. Note
that :user cannot be given interactively.

I wrote this funtion which uses authinfo and erc-tls to connect using sasl:
(defun salih/erc-connect ()
    "Connect to ERC with credentials from Authinfo."
  (interactive)
  (let* ((auth-info (auth-source-search :host "irc.libera.chat"
                                        :require '(:user :secret)))
         (user-id (plist-get (car auth-info) :user))
         (password (funcall (plist-get (car auth-info) :secret))))
    (erc-tls       :user     user-id
                   :password password)))

It can be modified to be used without authinfo.

source: Stack Exchange

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

sort: votes


text:
How to make an invisible overlay displaying other text clickable
I've been trying to add the ability to unfold with mouse by clicking on ellipsis in my json-mode, but after considerable time spent experimenting and looking through the Elisp manual, I can't figure out how to bind a function to clicking on the overlay I add when I fold.
Currently, my folding function looks like this:
(defun json-mode-hide-region (beg end)
  "Hides region from BEG to END with an overlay."
  (let ((overlay (make-overlay beg end))
        (map (make-sparse-keymap)))
    (define-key map [follow-link] (kbd "mouse-2"))
    (define-key map (kbd "mouse-2")
      (lambda (&rest args)
        (interactive)
        (delete-overlay overlay)))
    ;; FIXME: show hidden content in isearch before it's finished
    (overlay-put overlay 'invisible t)
    (overlay-put overlay 'isearch-open-invisible #'delete-overlay)
    (overlay-put overlay 'display json-mode-fold-ellipsis)
    (overlay-put overlay 'mouse-face 'highlight)
    (overlay-put overlay 'help-echo "mouse-2: unfold")
    (overlay-put overlay 'keymap map)
    (overlay-put overlay 'evaporate t)))

It's worth noting that I use lexical-binding to have proper lexical scoping and closures in my code, the entirety of which is in this repo. I've tried moving out the function that handles mouse-2 to a separate function, and even throwing errors in it, but it seems to never get called. It seems that documentation about making clickable buttons and links is mostly related to text properties, and overlays which don't make the original text invisible.
Does anyone know how to turn the display text into a link that calls a function when clicked (which deletes the overlay in my case)?

@Drew how is my question related to isearch? The mere fact that the code sample I put up has isearch-related code isn't relevant to the actual question at all.

On the one hand you set the invisible property to t on the other hand you set the display property to json-mode-fold-ellipsis. That combination does not make much sense. Use only one of those.
If you use the display property you should propertize the shown text with the keymap property -- not the text to be replaced.
You can test the following code in the *scratch* buffer.
Copy and paste it into the scratch buffer place point behind it and evaluate it with C-x C-e.
It inserts the text hidden text at point and puts an overlay with the string ... as display property on it.
The displayed string ... itself is propertized with the keymap property that defines the key <mouse-2> for removing the overlay (as in your code).
(eval
 '(let* ((map (make-sparse-keymap))
         (pos (point))
         (ol (progn
               (insert "hidden text")
               (make-overlay pos (point)))))
    (define-key map (kbd "<mouse-2>")
      (lambda ()
        (interactive)
        (delete-overlay ol)))
    (overlay-put ol 'display (propertize "..." 'keymap map)))
 t)

Your key-binding code is wrong, to start with.
This will get you started: use (kbd "<mouse-2>"), not (kbd "mouse-2").
Put (debug) in your lambda to continue debugging.
(Do that to start with, and you'll see that <mouse-2> is not bound to your command with your key binding - the debugger is not invoked. A call to message in your command would show the same thing.)
Always test your kbd sexp to see what it gives. It needs to give the key description - what C-h k shows.

Thanks for the suggestion. I think I've tried both ways to define the key, but since I normally don't deal with the mouse, I wasn't sure which one is correct.

You can quickly see the difference by doing what I suggested. (debug) and (message "Got here") are your friends, to see whether some code path is followed.

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


text:
Confused about .emacs vs .emacs.d/init.el
I read somewhere the two files were interchangeable, so I cut/paste the content of the former, shown below, to the latter. But then Xreader was missing when I tried to view a document generated by AUCTEX, which tells me they are not interchangeable.
 (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.  '(TeX-view-program-list (quote
 (("Xreader" ("xreader %o") "xreader"))))  '(TeX-view-program-selection
 (quote
     (((output-dvi has-no-display-manager)
       "dvi2tty")
      ((output-dvi style-pstricks)
       "dvips and gv")
      (output-dvi "xdvi")
      (output-pdf "Xreader")
      (output-html "xdg-open"))))) (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 'upcase-region 'disabled nil)

What are the different purposes of .emacs and .emacs.d/init.el?
UPDATE:
Here's the content of .emacs.d/init.el after the modification discussed above:
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(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.
 '(TeX-view-program-list (quote (("Xreader" ("xreader %o") "xreader"))))
 '(TeX-view-program-selection
   (quote
    (((output-dvi has-no-display-manager)
      "dvi2tty")
     ((output-dvi style-pstricks)
      "dvips and gv")
     (output-dvi "xdvi")
     (output-pdf "Xreader")
     (output-html "xdg-open")))))
(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 'upcase-region 'disabled nil)

They do not have different purposes, but only one of them gets used.  If you have a ~/.emacs file then ~/.emacs.d/init.el will not be read at all.

The related question https://emacs.stackexchange.com/q/1 will probably be helpful.

I redid cut/paste from .emacs to .emacs.d/init.el and deleted the former, and that does not solve the problem. The suggested post is that from which I got the idea to put init code in the second file.

Do C-h v TeX-view-program-list and C-h v TeX-view-program-selection include your Xreader values?  If so your problem is presumably something other than that config.

To @phils: with custom-set-variables set only in .emacs, the value of the first variable is (("Xreader" ("xreader %o") "xreader")). With .emacs.d/init.el set only in custom-set-variables, the same command returns 'no match'. This is consistent with the problem I have described.

Does C-h v user-init-file show you what you expect?

@phils. I get /home/er/.emacc, which is not a file that exists.

Just checking: the full path of .emacs.d is /home/er/.emacs.d, right?  If not, it should be!

I'm assuming .emacc was a typo on your part?  Yes, clearly Emacs sees your home directory as /home/er/, so /home/er/.emacs.d is correct. Check file permissions?  If ~/.emacs.d/init.el isn't readable by Emacs, it would fall back to the default ~/.emacs path (whether or not that latter file exists).

No, '. emacc' , that's Y I said it does not exist. ~/.emacs.d $ echo $PWD prints /home/er/.emacs.d. File permissions of either .emacs and /emacs.d/init.el are -rw-rw-r--

FYI, that name is not normal.  I do not know what to make of it.

.emacs.d
A folder containing emacs config files.

Located at ~/.emacs.d/

.emacs
An init/config file with personal EmacsLisp code used to configure emacs when it starts up.

Usually located at ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el.

init.el
Defaulted to by emacs during startup when the other .emacs and .emacs.el are both not available.

Usually located at ~/.emacs.d/init.el

custom set variables
(This is a response to a question asked about storing your custom-set-variables in some place other than the .emacs file)
Q: Can you store custom-set-variables in a place other than .emacs?
A: Yes
Many people do this by having their custom-set-variables inside their own file (lots of times called custom.el)
This is done by adding the following code into your main init file:
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)

Which will now load your custom-set-variables and  custom-set-faces from the file located in ~/.emacs.d/custom.el
Now inside your custom.el file (located in ~/.emacs.d/custom.el) you can have your custom-set-variables and custom-set-faces code.

on moving code from .emacs and init.el
I would be careful about where you put stuff and where emacs puts stuff, as sometimes they may not be the same place.
For example:

At one point I was adding config stuff in custom variables/custom themes that was in my .emacs file. I was loading a .org file into my .emacs file with extra config as well. But whenever I would evaluate my .emacs, the changes I made in the custom variables/custom themes weren't showing up all the time. Little did I know that the custom themes and custom variables that I was editing in my .emacs where not being evaluated by emacs at all and it was a completely different version that was getting evaluated which was located in my init.el file. So the only variables that would get loaded whenver I evaluated emacs where ones that I had set in emacs customize groups which were then getting placed in the init.el file and evaluated while what I was adding into the .emacs was being ignored.

To make a long story short: Be sure you know what emacs is really evaluating and what it isn't.

Can you improve formatting of your question? Directory names make more sense when they're showed in monospace (which you can achieve by surrounding them with backticks). Also, your explanation would be a bit better if you cleared up the wording and separated it into paragraphs.

~/.emacs.d/init.el is intended as an alternative name for ~/.emacs or ~/.emacs.el. It is not intended to be loaded manually from any other configuration files. See (emacs) Find Init.

@Basil you are correct. However I am just stating that it is possible to load it in. But I will add in that it is not meant to be loaded in like that but can if you so choose. Thanks!

@GabrielWolf Thanks for adding that clarification. Why mention the possibility of manually loading the file at all, though, when it is not recommended, non-standard, and when any file (including ~/.emacs and ~/.emacs.el) can also be manually loaded? What makes ~/.emacs.d/init.el so special in this regard compared to any other file?

@Basil nothing really. At one point I was using it by loading it into .emacs but I soon stopped. It was a silly beginner thing. I will remove it so that nobody will see it and immediately go and do it. Best.

FWIW one reason to explicitly load init.el from .emacs is if you have your .emacs.d under version control, and want to run some local/uncommitted elisp before or after the version-controlled init file.  I've heard of people using this approach, and it strikes me as an entirely reasonable way of achieving the underlying goal.

I don't think this answer helps the OP, btw.  It seems clear that the bizarre not-a-typo .emacc situation is the actual problem.

@phils yes that is true however the op also asked about the distinctions between .emacs .emacs.d and init.el so this was an answer geared towards that question.

The premise of the question being that .emacs and ./.emacs.d/init.el not interchangeable, "Be sure you know what emacs is really evaluating and what it isn't." doesn't make me feel much wiser.

@Erwann Well then I should hope that the beginning part explaining each of the differences will help you instead. The part at the end is just there to help anyone who might end up in the situation I was in. It isn't for everyone.

"Can the code (custom-set-variables... be evaluated in .emacs.d/init.el rather than .emacs, and how?" That  I would consider a helpful answer.

@Erwann I just added a section for that into my answer. Hope it helps!


text:
Marking a TODO item DONE does not create a CLOSING timestamp in org-mode
I'm following this tutorial:
https://orgmode.org/worg/org-tutorials/orgtutorial_dto.html
* Tasks
** DONE start a new org file for tutorial
C-c C-t

modifies the second to line
** DONE start a new org file for tutorial

but is not followed by the expected
CLOSED <timestamp>

What to do?
UPDATE #1:
here's how .emacs.d/init.el is setup:
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)

Try (setq org-log-done 'time).

In place or following (setq org-log-done t)? I tried both and it doesn't generate a timestamp. Also, C-x C-s does not save the task.

I assumed that org-log-done would be nil (default), so it's not the point. Anyway, my emacs -Q with your init setup works as expected...

I tried again and it worked with your solution.

Subsidiary question: how to do I close without a timestamp with the new setup?

Without setting org-log-done, timestamp will not be created when closing. It's default behavior. To ensure, you may explicitly set (setq org-log-done nil).


text:
How do you do a clean install of emacs+auctex?
It was established here there is a problem with my installation of emacs. So I did
$ sudo apt-get --purge autoremove emacs

and remove all in
$ locate emacs | grep conf

I reinstalled emacs from source (configure, make, make install). In the process, I had to do:
$sudo apt-get install emacs24-common
$sudo apt-get install libotf-bin
$sudo apt-get install libm17n-0

As this point I can get emacs to start. Then:
$ sudo apt-get install auctex

But the list of problems never ends. A suggestion?
$ sudo apt-get install auctex
Reading package lists... Done
Building dependency tree
Reading state information... Done
auctex is already the newest version (11.88-1.1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up emacs24 (24.5+1-6ubuntu1.1) ...
Install cmake-data for emacs24
install/cmake-data: Byte-compiling for emacs24
>>Error occurred processing cmake-mode.el: File error (("Opening input file" "no such file or directory" "/usr/share/emacs24/site-lisp/cmake-data/cmake-mode.el"))
Install emacsen-common for emacs24
emacsen-common: Handling install of emacsen flavor emacs24
>>Error occurred processing /etc/emacs24/site-start.d/00debian-vars.el: File error (("Opening input file" "no such file or directory" "/etc/emacs24/site-start.d/00debian-vars.el"))
>>Error occurred processing /usr/share/emacs24/site-lisp/debian-startup.el: File error (("Opening input file" "no such file or directory" "/usr/share/emacs24/site-lisp/debian-startup.el"))
ERROR: install script from emacsen-common package failed
dpkg: error processing package emacs24 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of auctex:
 auctex depends on emacs24 | emacs-snapshot; however:
  Package emacs24 is not configured yet.
  Package emacs-snapshot is not installed.

dpkg: error processing package auctex (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
         Errors were encountered while processing:
 emacs24
 auctex
E: Sub-process /usr/bin/dpkg returned an error code (1)

Other info:
$locate emacs

output

If you don't install emacs using apt you should install AUCTeX with the emacs package manager or from the source package https://www.gnu.org/software/auctex/download-for-unix.html


text:
Marking a TODO item DONE with or without a timestamp
it was established in a previous post that (setq org-log-done 'time) should be substituted for (setq org-log-done t) in the init file, so that C-c C-t would close a TODO with a timestamp. I would like to be able to choose between closing with or without a timestamp. How, please?
This is the current setup:
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
  ;;(setq org-log-done t)
(setq org-log-done 'time)
;; Conventional selection/deletion
(setq org-support-shift-select t)

The org-todo command documentation indicates that various prefix arguments can be used to influence the behavior. I thought perhaps this was what you wanted:
With a numeric prefix arg of 0, inhibit note taking for the change.

However, that doesn't seem to work for 'time.
You can create your own command that overrides the org-log-done setting, and bind it to some other key. Here's an example: this will run when org is loaded, define a variant of the org-todo command, and bind it to C-c C-S-t:
(with-eval-after-load 'org

    (defun my-org-todo-quietly ()
      (interactive)
      (let ((org-log-done nil))
        (org-todo)))

  (define-key org-mode-map (kbd "C-c C-S-t") 'my-org-todo-quietly))

You should then be able to use C-c C-t for the default behavior with the timestamp, or C-c C-S-t to skip the timestamp.

Where is the key?

Is C-S-t Ctrl-shift-t or Ctrl-upper case s-t? Neither works. Ctrl-uc S invokes schedule.

C-S-t is Ctrl-Shift-t. You can use a different key if you prefer, that one worked for me and seemed like a logical variant of the default C-c C-t.

Probably because I did not close the file (is there a way to reload init?), now I did and it worked, thank you.

Subsidiary question: M-x describe-key C-c C-t says C-c C-t not defined. It is defined.

Did you try describe-key from an org-mode buffer? That key is defined in a mode map so it will not be active unless you are currently in org-mode. You may want to take a look at the Emacs manual (which can be read within Emacs -- try C-h r to open it). See Evaluating Emacs Lisp Expressions for how to evaluate some new code in your init file without restarting; and Customizing Key Bindings for more on key maps.


text:
How do I silently write to a temporary file?
I made a modification in org-pomodoro to send the mode line to a pipe which I use in xmobar, but it keeps spamming my *Messages* buffer, thus making the line which displays it almost useless.
(write-region
 (concat "\ue003 "
         (org-pomodoro-format-seconds)
         (org-clock-get-clock-string)
         "\n")
 nil
 "/tmp/.todo-pipe")

I inserted the expression above in the "tick" function and everything is working as expected. Initially I made a shell script, but I think implementing the logic inside Emacs is a better solution, since I'm using org-pomodoro.

it keeps spamming my *Messages* buffer

I assume you're referring to the "Wrote FILENAME" message that write-region emits. This message can be inhibited by giving it a non-boolean, non-string value as the 5th VISIT argument. From the docstring of write-region:
If VISIT is neither t nor nil nor a string, or if Emacs is in batch mode,
  do not display the "Wrote file" message.

This is also documented in the Elisp manual under (elisp) Writing to Files.
So, you could write something like the following:
(write-region (concat "\ue003 "
                      (org-pomodoro-format-seconds)
                      (org-clock-get-clock-string)
                      "\n")
              nil "/tmp/.todo-pipe"
              nil 'quiet)

Thanks! That's it, I didn't noticed that when I was reading the documentation.


text:
auto-start of linum mode doesn't work
I'm currently using spacemacs.
I have put the line (global-linum-mode t) into the .spacemacs file but it doesn't work at all.
It used to work when I used the normal emacs.
I don't have any clue of what is going on. Apparently emacs --debug-init doesn't have any output.

Where have you inserted that? There isn't such a thing in my .spacemacs file.
   dotspacemacs-line-numbers '(:relative t
                               :disabled-for-modes dired-mode
                                                   doc-view-mode
                                                   markdown-mode
                                                   org-mode
                                                   pdf-view-mode
                                                   text-mode
                                                   nov-mode
                               :size-limit-kb 1000)

This is where you configure the line numbers mode in spacemacs, if you still want to do the emacs way, add your expression into init.el in the .emacs.d folder.


text:
How to delete ^M in the diffs of Magit?
I had an issue with a file that had inconsistent line ending. My file would show a ^M for every line ending. I ran into this article that shows how to get rid of the ^M character and set the buffer file encoding to fix the issue.
However, I still see the ^M character when I stage and commit my file in Magit. Magit show a file that has ^M as a line ending character even when I fixed this in the file buffer.
Do I need to make Magit aware of my file system encoding. If so, how?
Issue seen in macOS Mojave and Emacs 26.1.

I think this is more a git issue than an Emacs issue. Maybe the file is automatically detected as text file or it is marked as text file in .gitattributes. Mark the file type as binary in .gitattributes, do a git checkout MYFILENAME --, remove the Carriage Return just by query-replace, commit the file and restore the old version of .gitattributes. In the net there are recommodations to remove the index of the repository in such cases. That is a insensible sledge-hammer method that does not solve the actual problem (from my point of view). Don't follow that advice.

"how to delete ^M in magit pop-up buffer?" Magit Popup buffers are the dialog buffers that are used to show available key bindings -- they do not contain any diffs. I have changed the title accordingly.

Do I need to make Magit aware of my file system encoding. If so, how?

By configuring Git accordingly using core.eol and related variables described in git-config(1). By asking a search engine about "git end of file" you can find more information.
One complication when it comes to Magit is that it may display diffs for multiple files in the same Emacs buffer. The eol encoding can only be set per buffer, not for a certain area of the buffer, so Magit doesn't even try to use the correct encoding and just assumes lf.

You can configure magit to hide those trailing carriage return characters by setting magit-diff-hide-trailing-cr-characters to t.
This is particularly useful when editing Windows files from a Linux system e.g. when using Emacs under WSL (Windows Subsystem for Linux) to manage a git repo that was setup from the Windows side.


text:
how to append arbitrary string to yasnippet placeholder field
I would like to know how to append a default string to a placeholder.
For example, I currently have:
# -*- mode: snippet -*-
# name: render template
# key: rt
# group: Flask
# contributor: Jon Rostran
# --
render_template("${0:index.html}")

But I would like for rt to expand to render_template("|.html") where the | is my cursor position after expansion.

Was making things harder than I thought. Solved it with this render_template("$0.html")
EDIT:
Explanation
The default expansion of render_template("${0:index.html}") is render_template("index.html"), but I would like to save myself from overriding "index.html" and manage typing the .html extension by default. Thus, render_template("$0.html") allows me to type only the name of the file so that after expansion I start typing here render_template("|.html"), without overriding and typing .html part again.

Please elaborate - explain how that solves the problem (answers the question).

The default expansion of render_template("${0:index.html}") is render_template("index.html"), but I would like to save myself from overriding index.html and manage typing the .html extension by default. Thus, render_template("$0.html") allows me to type only the name of the file so after expansion I start typing here render_template("|.html"), without overriding and typing .html again.

Put all such explanation into the question or answer. Comments can be deleted at any time. Thx.


text:
Changing font size of a region or single characters
Is it possible in Emacs to change the font size of a single character or region, without affecting the whole Emacs window?

In Elisp programs (add-face-text-property (region-beginning) (region-end) '(:height 200)) does the trick. Replace 200 with the number of your choice. This only works for buffers without font-lock. If font-lock is active you need to add the :size face attribute via font-lock-add-keywords.

@tobias: Please consider posting your comment as an answer. Thx.

@Drew Hi, I was not sure whether the OP wanted an Elisp solution or an interactive one. But, you are right. If that is not what the OP wants one can just add another answer or extent that one.

In Elisp programs the following form does the trick for the text in the current region.
 (add-face-text-property (region-beginning) (region-end) '(:height 200))

Replace 200 with the number of your choice.
This only works for buffers without font-lock. If font-lock is active you need to add the :size face attribute via font-lock-add-keywords.

Evaluating the function above doesn't change anything. How should it be used?

@amirteymuri Please try it in text-mode or fundamental-mode with an active region. Afterwards switch to your actual target buffer and look what the value of font-lock-mode is. You can do that through direct evaluation by M-: font-lock-mode or by the help C-h v font-lock-mode. As I already stated in the answer that method does not work for buffers with font-lock-mode enabled. If you have such a buffer you  must more comprehensively describe what you want to achieve: Do you want to change the font size for some syntactical thing or is it a one-time change of a user-selected region?


text:
Emacs 26.2 can't load init file from Emacs 25
The title already says the question, i had Emacs 25 and compiled Emacs 26.2. Although my ./emacs directory and everything in it exists Emacs 26.2. starts complaining about packages which do not exist, although they exist. Why is this happening? Can any one help?

can you provide some of the actual error messages you are seeing?

Please don't give us any specific details, it would kill all the fun.

as said by others, you should provide the error messages. did you try to reinstall your packages?

As others have said: more info please.

What is a "./emacs directory" ?

Simplest thing to do: Recursively bisect your init file to find the piece(s) of it that are causing the problem.
You can do that by commenting out 1/2 of it, then 3/4, 7/8, 15/16, 31/32,...
You can do that by using command comment-region. With a plain prefix arg (C-u) it uncomments the region.
Once you have the problem narrowed down to a tiny bit of code, if it's not obvious what you need to do for that bit then post it here.  (And yes, always show complete error messages.)

Thanks, i already did so and was able to find and solve the problem.


text:
Replacement for the sit-for function
Using currently the sit-for function, every time i hit any key and cause user input the sit-for will stop. Is there any possibility to have something like sit-for, while being able to move the cursor around an typing and not causing any break of the process in run (with sleeping time intervals in it)?

So you want to, after a certain amount of time, run some code?
You can use a timer. In the simplest way of using it, you can pass it a number of seconds to wait, tell it not to repeat, then give it a lambda to run. For example:
(run-at-time 1     ;; in one second
             nil   ;; do NOT repeat
             (lambda ()    ;; this lambda is called
                     (message "I ran!")))

This will, in one second, call the lambda (lambda () (message "I ran!")). Replace the body of this lambda with the code you want to run.


text:
fixed file size mode
Is there an emacs mode/package/whatever where a specific file size (and/or number of lines) is enforced in a visual way?
Something like this:
1st line
2nd line

where adding some text to the 2nd line will result in
1st line
2nd usele
----
ss line

where the "\n----\n" marks the part that will be cut off, allowing the user to bring it back in by removing spaces from the lines before it?
(this is just an example, the thing could be of course nicer, and in the case the file gets shorter, extra newlines would be appended and highlighted with some color, etc).

I guess you're talking about having a maximum line length, where going past that length moves the extra text to the next line? Sounds a lot like like auto-fill-mode.

No, not a maximum line length. A fixed file size -- allowing the user to see the part which will be truncated -- and adjust the content until it fits. I'm pretty sure I've seen that somewhere.

Interesting question! How would emacs or user know how long file should be?


text:
How to save font alterations?
Let's say I have this in the buffer:

'BE BOLD'

I select it and type Alt-o b. It is now displayed as 'BE BOLD' I Save, quit, reopen: The font change is lost. How to keep the font change, please?

Do you enable Enriched Mode?

That answers the question, thanks.

@muffinmad: Please consider posting that as an answer, with a bit of explanation (summary), so it's not a link-only answer (which would be rejected). Comments can be deleted at any time. The aim is to have specific questions and answers, to help others too. Thx.

@Drew Ok. It was just a clarifying comment :)

@muffinmad: It seems like a (good) answer, to me.

To save text formatting properties use enriched-mode. Your file will be saved using text/enriched MIME format and will be looks like this:
Content-Type: text/enriched
Text-Width: 70

<bold>BE BOLD</bold>

Visiting such file will enable enriched-mode and restore text properties.


text:
How to express a literal |, not column separator, in a table?
If I press TAB, inside this table:
| foo     | bar |
| |        | @   |

I get this:
| foo | bar |   |
|     |     | @ |

I'm hoping there is a way to 'escape' the | in cell 2-1 to show that is it literal.

There is no way to escape |: the usual suggestion is to use \vert in the text instead of | - that does not look like a vertical bar in the emacs buffer of course (it looks like \vert :-) ), but when the document is exported (at least to LaTeX/PDF or HTML), you get the vertical bar you want:
| a                          | b   |
|----------------------------+-----|
| This has a \vert bar in it | foo |

The org-element-parser for table cells (org-version 9.2.3):
(defun org-element-table-cell-parser ()
  "Parse table cell at point.
Return a list whose car is `table-cell' and cdr is a plist
containing `:begin', `:end', `:contents-begin', `:contents-end'
and `:post-blank' keywords."
  (looking-at "[ \t]*\\(.*?\\)[ \t]*\\(?:|\\|$\\)")
  (let* ((begin (match-beginning 0))
     (end (match-end 0))
     (contents-begin (match-beginning 1))
     (contents-end (match-end 1)))
    (list 'table-cell
      (list :begin begin
        :end end
        :contents-begin contents-begin
        :contents-end contents-end
        :post-blank 0))))

There is no escape syntax defined for |.

If using Emacs's org-mode, you can display a vertical bar in a table field using the following method:

To insert a vertical bar into a table field, use \vert or, inside a word abc\vert{}def.


text:
Is there an equivalent to a spreadsheet's "freeze pane"?
I have an org file containing something like this:
|id   | foo         | bar       | ...
|-----+-------------+-----------| ...
|1    | foo1        | bar1      | ...
|2    | foo2        | bar2      | ...
|.    | .           | .         | .
|.    | .           | .         | .
|.    | .           | .         | .

I would like to split the window such that the id is always visible and/or the header is always visible, whichever line/column the cursor is set (that's very different from C-2 or C-3).
I'm aware that you can set a column width with <n>, which is a good substitute for splitting vertically, but to keep the headers visible?

Maybe there's something more convenient, but at least you could open a second window onto the same buffer, vertically above your current window, and keep the headers visible there.

It won't work if you scroll to the right.


text:
Expanding current column does not work as expected with a width cookie
From the manual:

C-c TAB (org-table-toggle-column-width)
Shrink or expand current column.

If a width cookie specifies a width W for the column, shrinking it
displays the first W visible characters only. Otherwise, the column is
shrunk to a single character.

When called before the first column or after the last one, ask for a list of column ranges to operate on.

Example:
| foo                                     | bar         |
|-----------------------------------------+-------------|
| <10> |
| foooooooooooo                           | barrrrr     |
| fooo                                    | barrrrrrrrr |
| foooooooooooooooooooooooooooooooooooooo | barrr       |

If I do C-c TAB, it does not shrink and I get the message "Before first heading" in the echo area. But if I do TAB, the first column shrinks. If I do TAB again, the cursor moves the next cell. If I do C-c TAB, it does not expand and I get the message "Before first heading" in the echo area.
Bottom line: I can shrink, not expand.

I can reproduce what you describe with org-mode 9.1.9. C-c TAB works like it is expected with org-mode 9.2.3.
In org-mode 9.1.19 C.c TAB runs outline-show-children while in 9.2.3 it runs  org-ctrl-c-tab with the following description:

Toggle columns width in a table, or show children.
  Call org-table-toggle-column-width if point is in a table.
  Otherwise, call org-show-children.

So, if you really want to get org-table-toggle-column-width working update to the org-version of org-mode or to the version at the gnu elpa package archive.
Org mode 9.2 was the first official version where org-ctrl-c-tab was bound to C-c TAB.


text:
Link and adjacent text get merged: how to preven that?
Say I start with:
{}{foo}

and insert a link inside the first pair of braces:
{https://emacs.stackexchange.com/questions/ask}{foo}

It will link to
https://emacs.stackexchange.com/questions/ask%7D%7Bfoo

How to prevent this?

What about using a space between } and {?  Or what about using the explicit notation of Org for links by using [[ and ]] instead of the curly braces that contain the url?

[[url]] inside braces works.


text:
Refresh code indentation over a region
I have this:
#!/usr/bin/bash

        while read f; do
            {

#Try
        echo "$f"

}

|| {

# Catch

printf "error"

}

    done < "${1:-/dev/stdin}";

And I would like this in one sweep
while read f; do
    {
        #Try
        echo "$f"
    } ||
    {
        # Catch

        printf "error"
    }
done < "${1:-/dev/stdin}";

For now I have to remove any blanks between the last properly indented line and the next one and do RET between the two, do the same with the next line, for all lines.

Why use RET rather than TAB?  (IOW, why/where did you learn to "abuse" RET this way but did not learn the use of TAB at the same time?)

Mark the region and press TAB to reindent it.

U are right Stefan, I must have been under some kind of spell for such inflicted hardship.

I'm still curious about the answer to my question (to see if there's something we could fix in some doc to avoid such hardship).

No, there is nothing in the doc that lead me to that, just a habit I picked up for whatever reason.


text:
Keybindigs conflict between minor modes
The configuration that I have for python mode implies loading both elpy.el and python.el. The things is that I found the python.el keybindings more natural than the elpy.el ones. And most of the python.el keybindings are shadowed by elpy.el.
I have tried adding a redefinition of the key map to the .emacs file, but it is not working.
This is my "raw" configuration for python
;; PYTHON CONFIGURATION
;; --------------------------------------

(elpy-enable)
(setq python-shell-interpreter "/home/anaconda3/bin/ipython"
      python-shell-interpreter-args "-i --simple-prompt")

;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

;; jedi config
;;----------------------------

(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
(add-hook 'after-init-hook 'global-company-mode)
(ac-config-default)

And this is the redefinition I have added:
(I have added an "e" after every "C-c")
(defvar elpy-mode-map
  (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c e C-r") elpy-refactor-map)
(define-key map (kbd "C-c e C-c") 'elpy-shell-send-region-or-buffer)
(define-key map (kbd "C-c e C-p") 'elpy-flymake-previous-error)
.
.
.

    map)
  "Key map for the Emacs Lisp Python Environment.")

It did not work.
How can I change the definition of those bindings without actually modifying the elpy.el file


text:
dired-do-copy in tramp does not go to local when `\ C-j` is pressed. File path stays in the same directory
I am using dired-do-copy to copy a file from remote using tramp to local.
When Copy file to path is promted. I used / C-j to go to local path but the path stays in the same directory , does not go to local root from remote.
I have also tried M-x copy-file , M-x gnus-copy-file and I have having the same issue as above.

Emacs version - 26.2
Local Os - MacOs
Remote server OS(Tramp) - RHEL
Swiper version - 20190708.1110

Steps to replicate -

Login to a remote using tramp
Open a directory in remote using dired.
Mark a file to copy, and run M-x dired-do-copy.
Swiper/IVY will prompt the path.
Type '/ C-j' to go to local.
The path stays the same.
Same thing happens to M-x copy-file in tramp mode too.

Trying to implement this functionality - https://superuser.com/questions/445564/how-do-you-copy-files-from-a-remote-server-to-a-local-folder-in-emacs-using-dire/445568
Also is there a way to disable counsel-find-file when dired-do-copy is triggered.

Try // or /~/ to get a local path. The remote path will be greyed out.

Welcome to emacs.SE! Please try to only ask one question per post.

@nega , Thanks for the reply. I am using Ivy. Please see the documentation for counsel-find-file here - https://oremacs.com/2019/07/20/ivy-0.12.0/ . '/ C-j' will take me to local root but the functionality does not work copy-file or dired-do-copy function is triggered.

Dunno about any of that junk. Normal Emacs works the way I described.

@user23911 It works for me using Ivy and Counsel.  The UI doesn't make it clear, but the '/' is shown following the full TRAMP path, and is fontified differently.  It becomes much more clear if you do something like '/tmp/'.  The prompt switches so that only the '/tmp' is shown, no more TRAMP path.  If you're getting different behavior it might be something in your setup.  Be sure to try with emacs -q

If your minibuffer contains a remote path, you could disable that by typing three slashes "///". See also the Tramp manual https://www.gnu.org/software/tramp/#File-name-completion

Hi Micheal, Thanks for the reply. I am sure this works in Vanilla emacs but This is not working when I am using Ivy. I have opened issue here - https://github.com/abo-abo/swiper/issues/2205. Also can you please let me know if I can disable Ivy when I run  M-x Copy-file in tramp?

Sorry, I don't use ivy.


text:
Do not open "GNU Emacs" buffer when launching Emacs
"GNU Emacs" buffer is opened automatically when launching Emacs(both terminal and GUI), and I have to kill that buffer everytime. It's boring.
How to turn "GNU Emacs" buffer off autimatically when launching Emacs.

You can put
(setq inhibit-startup-screen t)

into your init file. Then you start-up in the scratch buffer. You can use the variable initial-buffer-choice to set up your own preference.


text:
Association in Elisp not found
I have a simple alist in elisp like this:
(defvar *oneliners*
  '((js . "//")
    (python . "#")
    ))

I am a bit surprised that searching for the python key gives me nil. I am calling it from within the function:
(defun one (lang)
  (cdr (assoc lang *oneliners*)))

(one 'js) ;; -> "//"

But:
(one 'python) ;; -> nil

What am i missing about elisp's alists?

Note that the initial value is used only if the current value is void. That is, if you change the value in the defvar, then evaluate the defvar again, the value is not updated.  You can use setq to change the value (or use defconst instead of defvar).

If this turns out to be your problem, I'll post an answer detailing that.

Yes that was the problem, what is the elisp counterpart of CL defparameter?

I dont know CL so I can't say.

@amirt See https://emacs.stackexchange.com/questions/35294/is-there-an-equivalent-for-defparameter-on-emacs-lisp

One thing that may be unexpected with defvar is that (from its docstring):

The optional argument INITVALUE is evaluated, and used to set SYMBOL,
  only if SYMBOL’s value is void.

That is, if you change the initvalue in the defvar and evaluate it again (eg with eval-last-sexp, the new initvalue is not taken into account.  However, you can use the command eval-defun (bound to C-M-x in elisp-mode)

If the current defun is actually a call to ‘defvar’ or ‘defcustom’,
  evaluating it this way resets the variable using its initial value
  expression (using the defcustom’s :set function if there is one), even
  if the variable already has some other value.

Note that defconst does not have this behavior (from its docstring):

The ‘defconst’ form always sets the value of SYMBOL to the result of
  evalling INITVALUE.


text:
(goto-char (region-end)) doesn't set the point to the end of the region
I have written a small elisp script which should  put oneline or multiline comments based on the current buffer's major mode. The source file is here: https://github.com/amirteymuri/Com/blob/master/com.el
The insert-comm+ function which should insert the multiline comments however puts the ending multline-comment string not at the end of the marked region, but some characters before it (depending on major-mode the amount of characters change also). Can someone see where the problem is happening?
This is the insert-comm+ definition:
(defun insert-comm+ ()
  "Inserts multiliners to a marked region or a line."
  (interactive)
  (let* ((comm-list (comm+))
     (comm-begin (concat (first comm-list) "\n"))
     (comm-end (concat "\n" (second comm-list))))
    (if (use-region-p)
      (let ((b (region-beginning))
            (e (region-end)))
       (progn
        (goto-char b)
        (insert comm-begin)
        (goto-char (1+ e))
        (insert comm-end)))
      (progn
       (insert comm-begin)
       (insert comm-end)
       (backward-char (length comm-end))))))

You set e to the value of (region-end), which is the position of the end of the region at the time you call the function. Then you insert comm-begin somewhere before e. So e is no longer at the end of the region, but n characters before where n is the length of comm-begin. I guess you tried to compensate by using (1+ e) instead of e, but that only gives the right result if comm-begin is a single character.
The proper fix is simple: retrieve the region boundaries only when you need them.
You should also decide whether you want to end up with the comment delimiters inside or outside the region and use insert-before-markers accordingly. Use it to insert the beginning delimiter to keep the delimiters outside the region, or to insert the end delimiter to keep the delimiters inside.
(if (use-region-p)
    (progn
      (goto-char (region-beginning))
      (insert-before-markers comm-begin)
      (goto-char (region-end))
      (insert comm-end))
  (insert comm-begin)
  (insert-before-markers comm-end))

Also, you should wrap this function in save-excursion so that it leaves the point in place instead of moving it to the end.
Overall, I don't understand what you're trying to do. Emacs already knows how to begin and end a comment in all major modes: the information is in the variables comment-start and comment-end. And Emacs already has commands to comment out a region.


text:
How to generate directory structure out of org-mode outline?
I want to create the directory tree structure like this out of org-mode outlines.

Dir1

Dir-1.1

Dir -1.1.1

Dir-1.2

Dir 2

Dir-2.1
Dir-2.2

I am new to emacs and I have tried a few shell commands from here like
  xargs -d '\n' mkdir -p -- < test.txt

For that to work I need a file with the following structure.
# Test.txt
A1/A2/A3
B1/B2/B3
C1/C2/C3

TLDR: Generate Directory structure out of org outlines.

org-element-parse-buffer and org-element-map are your friends.
You get the doc strings of these two functions (and of every other function) by C-h f.
The following function org-headlines-to-dir-tree parses the org buffer via org-element-parse-buffer and creates the directories corresponding to the headlines via org-element-map.
This is pure Elisp. No shell commands are required.
(defun org-headlines-to-dir-tree (dir &optional data)
  "Transform org headlines in DATA to directory tree below DIR.
DATA defaults to the headline structure of the current org buffer."
  (interactive "DTarget directory:")
  (unless data
    (unless (derived-mode-p 'org-mode)
      (user-error "%S is not an org buffer" (current-buffer)))
    (setq data (org-element-parse-buffer 'headline)))
  (unless (file-directory-p dir)
    (user-error "%S is not a directory" dir))
  (let ((default-directory (expand-file-name dir)))
    (org-element-map
        data
        'headline
      (lambda (el)
        (let ((title (org-element-property :title el))
              (contents (org-element-contents el)))
          (when (y-or-n-p (format "Create directory %S?" (expand-file-name title)))
            (mkdir title)
            (when contents
              (org-headlines-to-dir-tree title contents))))) ;; Recursion.
      nil ;; info
      nil ;; first match
      'headline ;; no-recursion (We do the recursion ourselves with additional directory changes.)
      )))

You can paste that stuff into your *scratch* buffer and evaluate it by placing point in to the function body and typing C-M-x.


text:
use-package can't load package at startup
When I start Emacs I get the error message

Error (use-package): Cannot load counsel

But when I open init.el in a buffer and run eval-buffer everything works fine. What I'm doing wrong?
My Emacs config: https://git.sr.ht/~inquisitive/emacs-adjustments/tree/package/ivy/.emacs.d/init.el
;; Bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)

(use-package magit
  :bind ("C-x g" . magit-status))

(use-package counsel
  :config
  (counsel-mode 1))

;; Display line numbers in programming major modes
(add-hook 'prog-mode-hook 'display-line-numbers-mode)

(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.
 '(inhibit-startup-screen t)
 '(menu-bar-mode nil)
 '(scroll-bar-mode nil)
 '(straight-use-package-by-default t)
 '(tool-bar-mode nil))
(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.
 '(default ((t (:inherit nil :stipple nil :background "#fcfcfc" :foreground "#232627" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 143 :width normal :foundry "FSD " :family "PragmataPro Mono Liga")))))

perhaps counsel isn't installed? try M-x package-install <ret> counsel <ret>

@manandearth: If the package isn't already installed it should be automatically installed with straight.el.

You need to add the straight keyword in the use-package macro call e.g. add :straight t
From straight.el documentation https://github.com/raxod502/straight.el#integration-with-use-package

To use use-package, first install it with straight.el:
(straight-use-package 'use-package)

Now use-package will use straight.el to automatically install missing packages if you provide :straight t:
(use-package el-patch
    :straight t)

It seems that the bug occurs because I set straight-use-package-by-default using the customize-interface. When I set the variable outside of custom-set-variables everything works fine.

I don't understand why that would be the case: can someone explain? A more likely reason to my mind is that the initialization of the variable has to happen earlier (e.g. before you use straight-use-package for the first time), but this is only a guess: I have not checked anything. OTOH, if you are right, I really would like to know why.

In general you need to initialize the package system if you're going to use packages at init time.
i.e. Do this first:
(setq package-enable-at-startup nil)
(package-initialize)

(That said, I'd be slightly surprised if use-package didn't do that itself, so maybe this isn't the issue; but it's certainly worth testing it.)

OP is using straight.el and does not use package use-package can use both

Does straight have an equivalent to package-initialize then?

Yes it ius somethink like the bootstrap  code in the question - however I don't use it and don't know what the OP has miscopied or misunderstood

Ok, thanks.  I'll leave this answer here as extra information for others.


text:
Scilab-mode syntax highlighting
I'm trying to install (and run) scilab-mode, but the syntax highlighting does not work when I open .sci or .sce file.
I use the exact configuration described in the scilab.el package.
https://www.emacswiki.org/emacs/scilab.el
Any help?

With so few details about what you've done, it will likely take psychic powers to figure out the solution.

For the beginning you can reduce your setup to (defvar default-fill-column (default-value 'fill-column)) (autoload 'scilab-mode "scilab") (add-to-list 'auto-mode-alist '("\\.\\(sci\\|sce\\)\\'" . scilab-mode)). Try that and report whether scilab-mode works for you afterwards. Note, that this does not include scilab-shell yet.

Note that posting: https://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00542.html about default-fill-column.

Note that the above setup does not include scilab-shell yet. For scilab-shell to work you have to setup scilab-shell-command, e.g. by (defvar scilab-shell-command) (setq scilab-shell-command "scilab-adv-cli") (autoload 'scilab-shell "scilab"). But, they removed scilex from scilab. So I do not know whether scilab-shell will work as expected for you. (Note, that I do not use scilab anymore so much. I use octave instead because of Cygwin support and Matlab compatibility.)

The help page clearly says that this is an old script which does not work with the current version of Emacs without adapting it. It's really a shame and I would also be interested, but this elisp script is simply orphaned.

It's probably quite easy to update the package.  I'd have done it already if the copyright paperwork allowed it to be included in GNU ELPA.  But I can't even find a currently valid email for its author Alexander Vigodner :-(


text:
Avoid installing package to ".emacs.d/elpa/" directory
I install yasnippet from the repository using the package manager and I add the corresponding directory to the load path before (use-package yasnippet):
    ;; Add all subdirs in site-lisp to the load-path
    (let ((default-directory "/usr/share/emacs/site-lisp/"))
      (normal-top-level-add-subdirs-to-load-path))

but when I start emacs it installs the package (despite of the load path) in the ".emacs.d/elpa/" directory.
Is there a way to avoid it?

Possible duplicate of Install packages globallly

@matteol it is not an duplicate of the linked question

@Banish It should not do this, could you show your use-package sexp for yasnippet? When running emacs without your config emacs -q, is yasnippet available? (it should, because it is loaded by system wide emacs init scripts)

@jue Do you mean init.el configuration for yasnippet:
;; Yasnippet
;; check documentation for all scripts for the corresponding language
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1)
)

When I execute the following lisp code:
(print load-path)

I get the list of all directories in the load path including /usr/share/emacs/site-lisp/ with all subdirectories.
I've tried the following:
;; Undo Tree
;; using C-x u to choose and q to quit/undo/ to the step
(use-package undo-tree
  :ensure t
  :init
  (global-undo-tree-mode)
  )

and the package was automatically installed in "~/.emacs.d/elpa/".
but when I've commented the ":ensure t" and delete the package from ".../elpa" but installed wit the package manager to "/usr/share/emacs/site-lisp/" I still had the undo-tree package but from the common directory.
(use-package undo-tree
  :init
  (progn
    (require 'undo-tree)
    (global-undo-tree-mode)
    ))

Problem solved!

Of course, this is what the :ensure keyword is for. Read at the use-package documentation


text:
How to enable Backtrace?
I'm following the tutorial's "Making error": reproduced in the screenshot below. The manufactured error does not open the Backtrace window as it should. The same page says "It is possible to prevent Emacs entering the debugger in cases like this. [...] in the echo area and look like this:
 Symbol's function definition is void: this

". And that is indeed what I get. Thus my question: how to switch on the backtrace feature?

I don't know why the manual doesn't specify that you need to first type M-x toggle-debug-on-error or evaluate (setq debug-on-error t).  Perhaps the manual needs to be revised to instruct the user to first enable debugging before performing the test ....  However, I haven't memorized the manual, so maybe it says it somewhere and it's just not obvious.

This is on account of C-h v eval-expression-debug-on-error, which is t by default; so when the user evals the invalid code, they ought to get the expected backtrace.  xuchunyang has spotted the reason for it not happening in this case.

In your mode line, [...] suggests you have an existing backtrace is running, you need to quit this one in order to trigger a new backtrace, you can do this by C-x b *Backtrace* and q.
If there is something in the mode line you don't understand, you can use mouse hover to see the tooltip. For example, if you hover [ or ], it will say something like "Recursive edit, type C-M-c to get out". (emacs) Recursive Edit is a feature that allow users continue to use Emacs without quit the current command, in this debugging case, you can use continue to use Emacs as usual while you're debugging Emacs itself. To quit one Recursive edit, you can use C-M-c (exit-recursive-edit, one level) or C-] (abort-recursive-edit, all levels) or M-x top-level (actually q in the end of the first paragraph runs top-level).

OP: The mode-line indication that you are in a recursive edit ([...]) is not very noticeable. If you'd like to see it be more noticeable, and even indicate different levels of recusion-depth, you can use library rec-edit.el for that.


text:
C-M-\ fails to indent Lisp code
I follow this tutorial. The code after selecting the region and <Tab> or equivalently C-M-\ in an org file:
(setq trees '(pine fir oak maple)
herbivores '(gazelle antelope zebra))

I would have expected an indent before "herbivores".

indent-region indents the region according to the current mode.
In a Lisp mode (e.g. emacs-lisp-mode), selecting that as the region and using TAB indents it as you say you expect, not as you show.
Why would expect it to behave similarly in Org mode?
(The section of the tutorial that you cite doesn't say anything about indentation, BTW.)
C-h f indent-region tells us:

indent-region is an interactive compiled Lisp function in indent.el.
It is bound to C-M-\, menu-bar edit region indent-region`.
(indent-region START END &optional COLUMN)
Indent each nonblank line in the region.
A numeric prefix argument specifies a column: indent each line to that column.
With no prefix argument, the command chooses one of these methods and
  indents all the lines with it:

If fill-prefix is non-nil, insert fill-prefix at the
      beginning of each line in the region that does not already begin
   with it.
If indent-region-function is non-nil, call that function
   to indent the region.
Indent each line via indent-according-to-mode.

Called from a program, START and END specify the region to indent.
  If the third argument COLUMN is an integer, it specifies the
  column to indent to; if it is nil, use one of the three methods above.

Next, read what C-h f tells you about indent-region-function in a Lisp mode, and what it tells you about indent-according-to-mode.


text:
How to schedule exclusively with the keyboard?
If you look a the screenshot the cursor is locked in the echo area. If want to select the date, I have to click on one with the mouse. Do I, or there is a way to do with the keyboard?
EDIT:
Also the navigation key bindings don't work as they're supposed to. If I do C-f, it does not move one day forward whether in conjunction with Shift or not.

The words "Date+time" come from the function org-read-date in the org.el library.  I have added the tag org-mode to the question so people do not mistakenly think this is strictly relating to the calendar library.  For anyone who wishes to work on this question, evaluate (require 'org) and then evaluate (org-read-date) ....

Hold down the shift key while you use the arrows.  Shift-right and left will move by days, Shift-up and down by weeks. Alt-Shift right and left will move by months, and Alt-Shift up and down will move by years.

The key bindings are provided by org-read-date-minibuffer-local-map.

There is a lot of inputs you can give to specify a date or time. The whole overview is here. Just some notable examples:

Relative dates:

+1 or just +: tomorrow
+1w: next week
sat: next saturday

Absolute dates are a bit weird. It uses ISO YMD format by default: 3-2-5 expands to 2003-02-05. I prefer to use 23 jan 19 or 23 jan 2019 (equal to 19-1-23) to use a DMY format.
To add a time to any date selection use 11am or 11:00

Some Calendar movements also work. Shift+Arrows moves by days. > and < shift the months displayed, ... See Calendar motion and Scroll calendar of the Emacs Calendar manual.
Here's a screenshot where I select the monday in two weeks at 11am by entering +2mon 11am. The date prompt gets updated to indicate my selected date => <2019-11-25 Mon 11:00>. Press Enter to confirm and exit.

About the Calendar motion: g d     Move point to specified date (calendar-goto-date).  I don't know what key combo g d is.

Are you supposed to type +1w in the echo area?

Yes, just type it. The displayed date in the echo area should change and you can confirm with Enter. Commands like C-a, C-f or single letters do not work as they are intercepted by the minibuffer.

OK, it worked. Is the minibuffer the same as the echo area?

Basically yes. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Echo-Area.html

They are completely different.  The one thing they share is a window.  That window displays either the minibuffer, or the echo area, depending on what is happening.  The minibuffer is (per its name) a buffer you can type into.  The echo area (per its name) just displays things.  Sometimes something which is capturing keystrokes will echo them to the echo area as you type, however (isearch is a classic example), which can confuse matters.  They are categorically not the same thing, though.

@Daniel's answer should be the official solution. But I find you can still just C-x o to move the cursor to the calendar buffer, then move around as usual and hit RET to pick a date. Though you will not see the cursor because the org mode turns it off, you can get it back via M-x (setq cursor-type t).

@xuchungyang C-x o switches to buffer from which I did C-c C-s, not the calendar, in my case.

@Erwann You probably have switched to the calendar buffer, though you don't notice since the cursor is hided as I explained in the last sentence.

@xuchungyang, the whole sequence. 1) starting from "original buffer": C-c C-s, opens calendar, cursor in echo area. 2) C-x o, cursor flickers in original buffer. 3) M-x prompts: command attempted to use minibuffer while in minibuffer.

@Erwann C-x o runs other-window. In this case, there are at least THREE windows, that is, the minibuffer window, the org mode file buffer window and the calendar buffer window. So use C-x o to switch to the calendar buffer window. You might need to use C-x o more than once.

@xuchunyang: you should porbably add your last comment into the answer.


text:
Help with basic diary/calendar features
I have created two diary entries, I can't see them in the week agenda. Why is that? Also I would have expected 11/15 to be highlighted, or something like that, to indicate an event was planned that day.

I didn't know Org Agenda can work with Diary since they are two separate apps. Then I searched the org manual with keyword diary, and found this on (info "(org) Weekly/daily agenda"):

In order to include entries from the Emacs diary into Org mode’s
  agenda, you only need to customize the variable
(setq org-agenda-include-diary t)

That variable defaults to nil.

Now that the diary entries come up in the agenda, I would have thought M-x org-agenda-to-appt would produce something. I get, instead, "no event to add". What are events, then?

@Erwann hmm, I can't help. I am not familiar with org-agenda/diary.


text:
(un)-Indenting text over a region
This in org mode. How do I get from

1 to 2
2 to 3

in as few keystrokes as possible? And, if possible, in reverse. I was hoping selecting Food's subtree and M-^ would do the job but what it does instead is delete subsequent lines.
1
* Food
    This is the body,
    which says something about the topic of food.

** Delicious Food
    This is the body of the second-level header.

** Distasteful Food
    This could have
    a body too, with
    several lines.

*** Dormitory Food

* Shelter
    Another first-level topic with its header line.

2
* Food
This is the body,
which says something about the topic of food.

** Delicious Food
This is the body of the second-level header.

** Distasteful Food
This could have
a body too, with
several lines.

*** Dormitory Food

* Shelter
Another first-level topic with its header line.

3
* Food
  This is the body,
  which says something about the topic of food.

** Delicious Food
   This is the body of the second-level header.

** Distasteful Food
   This could have
   a body too, with
   several lines.

*** Dormitory Food

* Shelter
  Another first-level topic with its header line.

From 1, 3 to 2

Select all text: C-x h
Remove indentation: M-x close-rectangle RET

(Although kind of a hacky use of close-rectangle.)
From 1, 2 to 3

Select all text: C-x h
indent-region: C-M-\

From 3 to 1
With point at start of buffer:
M-x replace-regexp RET
^ + RET <4 spaces> RET

C-x h C-M-\ goes directly from 1 to 3
The first part (C-x h) runs the command mark-whole-buffer, the second (C-M-\) runs indent-region.
You can go from 1 or 3 to 2 with C-M-% ^ + RET RET, that runs the command query-replace-regexp to replace any sequence of whitespaces at the beginning of line with nothing.
I don't know how to easily revert the change.


text:
Export settings: +TITLE causes error
In org mode I do C-c C-e t u 1) with or 2) without the title. 2) works fine. For 1), this is what I get in the minibuffer (echo area):

apply: Wrong type argument: listp, #("XYZ" 0 5 (:parent (#0)))

What's wrong with it?
#+TITLE: XYZ
#+EXPORT_FILE_NAME: ~/Documents/Outbox/test
#+OPTIONS: ^:nil

* Food
    This is the body,
    which says something about the topic of food.

** Delicious Food
    This is the body of the second-level header.

** Distasteful Food
    This could have
    a body too, with
    several lines.

*** Dormitory Food

* Shelter
    Another first-level topic with its header line.

Relevant help page:
https://www.gnu.org/software/emacs/manual/html_node/org/Export-settings.html

UPDATE #1:

UPDATE #2:
GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
UPDATE #3 on 11/26
C-u M-x org-reload
M-x toggle-debug-on-error
Backtrace:
Debugger entered--Lisp error: (wrong-type-argument listp #("XYZ" 0 3 (:parent (#0))))
  org-element-set-contents(#("XYZ" 0 3 (:parent (#0))))
  apply(org-element-set-contents #("XYZ" 0 3 (:parent (#0))) nil)
  #f(compiled-function (s) #<bytecode 0x141eba1>)(#("XYZ" 0 3 (:parent (#0))))
  #f(compiled-function (--data) #<bytecode 0x13f4f9d>)(#("XYZ" 0 3 (:parent (#0))))
  mapc(#f(compiled-function (--data) #<bytecode 0x13f4f9d>) (#("XYZ" 0 3 (:parent (#0)))))
  #f(compiled-function (--data) #<bytecode 0x13f4f9d>)((#("XYZ" 0 3 (:parent (#0)))))
  org-element-map((#("XYZ" 0 3 (:parent (#0)))) plain-text #f(compiled-function (s) #<bytecode 0x141eba1>))
  org-export--get-inbuffer-options(#s(org-export-backend :name latex :parent nil :transcoders ((bold . org-latex-bold) (center-block . org-latex-center-block) (clock . org-latex-clock) (code . org-latex-code) (drawer . org-latex-drawer) (dynamic-block . org-latex-dynamic-block) (entity . org-latex-entity) (example-block . org-latex-example-block) (export-block . org-latex-export-block) (export-snippet . org-latex-export-snippet) (fixed-width . org-latex-fixed-width) (footnote-definition . org-latex-footnote-definition) (footnote-reference . org-latex-footnote-reference) (headline . org-latex-headline) (horizontal-rule . org-latex-horizontal-rule) (inline-src-block . org-latex-inline-src-block) (inlinetask . org-latex-inlinetask) (italic . org-latex-italic) (item . org-latex-item) (keyword . org-latex-keyword) (latex-environment . org-latex-latex-environment) (latex-fragment . org-latex-latex-fragment) (line-break . org-latex-line-break) (link . org-latex-link) (node-property . org-latex-node-property) (paragraph . org-latex-paragraph) (plain-list . org-latex-plain-list) (plain-text . org-latex-plain-text) (planning . org-latex-planning) (property-drawer . org-latex-property-drawer) (quote-block . org-latex-quote-block) (radio-target . org-latex-radio-target) (section . org-latex-section) (special-block . org-latex-special-block) (src-block . org-latex-src-block) (statistics-cookie . org-latex-statistics-cookie) (strike-through . org-latex-strike-through) (subscript . org-latex-subscript) (superscript . org-latex-superscript) (table . org-latex-table) (table-cell . org-latex-table-cell) (table-row . org-latex-table-row) (target . org-latex-target) (template . org-latex-template) (timestamp . org-latex-timestamp) (underline . org-latex-underline) (verbatim . org-latex-verbatim) (verse-block . org-latex-verse-block) (latex-math-block . org-latex-math-block) (latex-matrices . org-latex-matrices)) :options ((:latex-class "LATEX_CLASS" nil org-latex-default-class t) (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t) (:latex-header "LATEX_HEADER" nil nil newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline) (:description "DESCRIPTION" nil nil parse) (:keywords "KEYWORDS" nil nil parse) (:subtitle "SUBTITLE" nil nil parse) (:latex-active-timestamp-format nil nil org-latex-active-timestamp-format) (:latex-caption-above nil nil org-latex-caption-above) (:latex-classes nil nil org-latex-classes) (:latex-default-figure-position nil nil org-latex-default-figure-position) (:latex-default-table-environment nil nil org-latex-default-table-environment) (:latex-default-table-mode nil nil org-latex-default-table-mode) (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format) (:latex-footnote-defined-format nil nil org-latex-footnote-defined-format) (:latex-footnote-separator nil nil org-latex-footnote-separator) (:latex-format-drawer-function nil nil org-latex-format-drawer-function) (:latex-format-headline-function nil nil org-latex-format-headline-function) (:latex-format-inlinetask-function nil nil org-latex-format-inlinetask-function) (:latex-hyperref-template nil nil org-latex-hyperref-template t) (:latex-image-default-height nil nil org-latex-image-default-height) (:latex-image-default-option nil nil org-latex-image-default-option) (:latex-image-default-width nil nil org-latex-image-default-width) (:latex-images-centered nil nil org-latex-images-centered) (:latex-inactive-timestamp-format nil nil org-latex-inactive-timestamp-format) (:latex-inline-image-rules nil nil org-latex-inline-image-rules) (:latex-link-with-unknown-path-format nil nil org-latex-link-with-unknown-path-format) (:latex-listings nil nil org-latex-listings) (:latex-listings-langs nil nil org-latex-listings-langs) (:latex-listings-options nil nil org-latex-listings-options) (:latex-minted-langs nil nil org-latex-minted-langs) (:latex-minted-options nil nil org-latex-minted-options) (:latex-prefer-user-labels nil nil org-latex-prefer-user-labels) (:latex-subtitle-format nil nil org-latex-subtitle-format) (:latex-subtitle-separate nil nil org-latex-subtitle-separate) (:latex-table-scientific-notation nil nil org-latex-table-scientific-notation) (:latex-tables-booktabs nil nil org-latex-tables-booktabs) (:latex-tables-centered nil nil org-latex-tables-centered) (:latex-text-markup-alist nil nil org-latex-text-markup-alist) (:latex-title-command nil nil org-latex-title-command) (:latex-toc-command nil nil org-latex-toc-command) (:latex-compiler "LATEX_COMPILER" nil org-latex-compiler) (:date "DATE" nil "\\today" parse)) :filters ((:filter-options . org-latex-math-block-options-filter) (:filter-paragraph . org-latex-clean-invalid-line-breaks) (:filter-parse-tree org-latex-math-block-tree-filter org-latex-matrices-tree-filter org-latex-image-link-filter) (:filter-verse-block . org-latex-clean-invalid-line-breaks)) :blocks nil :menu (108 "Export to LaTeX" ((76 "As LaTeX buffer" org-latex-export-as-latex) (108 "As LaTeX file" org-latex-export-to-latex) (112 "As PDF file" org-latex-export-to-pdf) (111 "As PDF file and open" (lambda (a s v b) (if a (org-latex-export-to-pdf t s v b) (org-open-file ...))))))))
  org-export-get-environment(#s(org-export-backend :name latex :parent nil :transcoders ((bold . org-latex-bold) (center-block . org-latex-center-block) (clock . org-latex-clock) (code . org-latex-code) (drawer . org-latex-drawer) (dynamic-block . org-latex-dynamic-block) (entity . org-latex-entity) (example-block . org-latex-example-block) (export-block . org-latex-export-block) (export-snippet . org-latex-export-snippet) (fixed-width . org-latex-fixed-width) (footnote-definition . org-latex-footnote-definition) (footnote-reference . org-latex-footnote-reference) (headline . org-latex-headline) (horizontal-rule . org-latex-horizontal-rule) (inline-src-block . org-latex-inline-src-block) (inlinetask . org-latex-inlinetask) (italic . org-latex-italic) (item . org-latex-item) (keyword . org-latex-keyword) (latex-environment . org-latex-latex-environment) (latex-fragment . org-latex-latex-fragment) (line-break . org-latex-line-break) (link . org-latex-link) (node-property . org-latex-node-property) (paragraph . org-latex-paragraph) (plain-list . org-latex-plain-list) (plain-text . org-latex-plain-text) (planning . org-latex-planning) (property-drawer . org-latex-property-drawer) (quote-block . org-latex-quote-block) (radio-target . org-latex-radio-target) (section . org-latex-section) (special-block . org-latex-special-block) (src-block . org-latex-src-block) (statistics-cookie . org-latex-statistics-cookie) (strike-through . org-latex-strike-through) (subscript . org-latex-subscript) (superscript . org-latex-superscript) (table . org-latex-table) (table-cell . org-latex-table-cell) (table-row . org-latex-table-row) (target . org-latex-target) (template . org-latex-template) (timestamp . org-latex-timestamp) (underline . org-latex-underline) (verbatim . org-latex-verbatim) (verse-block . org-latex-verse-block) (latex-math-block . org-latex-math-block) (latex-matrices . org-latex-matrices)) :options ((:latex-class "LATEX_CLASS" nil org-latex-default-class t) (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t) (:latex-header "LATEX_HEADER" nil nil newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline) (:description "DESCRIPTION" nil nil parse) (:keywords "KEYWORDS" nil nil parse) (:subtitle "SUBTITLE" nil nil parse) (:latex-active-timestamp-format nil nil org-latex-active-timestamp-format) (:latex-caption-above nil nil org-latex-caption-above) (:latex-classes nil nil org-latex-classes) (:latex-default-figure-position nil nil org-latex-default-figure-position) (:latex-default-table-environment nil nil org-latex-default-table-environment) (:latex-default-table-mode nil nil org-latex-default-table-mode) (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format) (:latex-footnote-defined-format nil nil org-latex-footnote-defined-format) (:latex-footnote-separator nil nil org-latex-footnote-separator) (:latex-format-drawer-function nil nil org-latex-format-drawer-function) (:latex-format-headline-function nil nil org-latex-format-headline-function) (:latex-format-inlinetask-function nil nil org-latex-format-inlinetask-function) (:latex-hyperref-template nil nil org-latex-hyperref-template t) (:latex-image-default-height nil nil org-latex-image-default-height) (:latex-image-default-option nil nil org-latex-image-default-option) (:latex-image-default-width nil nil org-latex-image-default-width) (:latex-images-centered nil nil org-latex-images-centered) (:latex-inactive-timestamp-format nil nil org-latex-inactive-timestamp-format) (:latex-inline-image-rules nil nil org-latex-inline-image-rules) (:latex-link-with-unknown-path-format nil nil org-latex-link-with-unknown-path-format) (:latex-listings nil nil org-latex-listings) (:latex-listings-langs nil nil org-latex-listings-langs) (:latex-listings-options nil nil org-latex-listings-options) (:latex-minted-langs nil nil org-latex-minted-langs) (:latex-minted-options nil nil org-latex-minted-options) (:latex-prefer-user-labels nil nil org-latex-prefer-user-labels) (:latex-subtitle-format nil nil org-latex-subtitle-format) (:latex-subtitle-separate nil nil org-latex-subtitle-separate) (:latex-table-scientific-notation nil nil org-latex-table-scientific-notation) (:latex-tables-booktabs nil nil org-latex-tables-booktabs) (:latex-tables-centered nil nil org-latex-tables-centered) (:latex-text-markup-alist nil nil org-latex-text-markup-alist) (:latex-title-command nil nil org-latex-title-command) (:latex-toc-command nil nil org-latex-toc-command) (:latex-compiler "LATEX_COMPILER" nil org-latex-compiler) (:date "DATE" nil "\\today" parse)) :filters ((:filter-options . org-latex-math-block-options-filter) (:filter-paragraph . org-latex-clean-invalid-line-breaks) (:filter-parse-tree org-latex-math-block-tree-filter org-latex-matrices-tree-filter org-latex-image-link-filter) (:filter-verse-block . org-latex-clean-invalid-line-breaks)) :blocks nil :menu (108 "Export to LaTeX" ((76 "As LaTeX buffer" org-latex-export-as-latex) (108 "As LaTeX file" org-latex-export-to-latex) (112 "As PDF file" org-latex-export-to-pdf) (111 "As PDF file and open" (lambda (a s v b) (if a (org-latex-export-to-pdf t s v b) (org-open-file ...))))))) nil (:output-file "debug_title.tex"))
  org-export-as(latex nil nil nil (:output-file "debug_title.tex"))
  org-export-to-file(latex "debug_title.tex" nil nil nil nil nil)
  (let ((outfile (org-export-output-file-name ".tex" subtreep))) (org-export-to-file (quote latex) outfile async subtreep visible-only body-only ext-plist))
  org-latex-export-to-latex(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  call-interactively(org-export-dispatch nil nil)
  command-execute(org-export-dispatch)

Make org-mode export with C-c C-e t u instead C-x C-e t u. Also note the TITLE by itself is a keyword, so no need to repeat it in first line and C-x C-e enters debug mode.

@Ian C-x was a typo, I corrected it. TITLE may have been a poor example, but the error remains if I change it to xyz. Syntax highlighting shows there is something wrong with that line.

FWIW, I don't see the problem (but the setting of EXPORT_FILE_NAME caused me problems, so I changed it - see below). The PDF is produced fine. The syntax highlighting does look different, but that's fine: the TITLE face is org-document-info-keyword  whereas for the other two, it is org-meta-line -  which makes sense. For the EXPORT_FILE_NAME setting a) I could not use ~: that's a shell abbreviation that I guess is not acceptable in this context, b) but even when I replaced it with an absolute pathname, I still had problems because ...

...  the various tools  I use (latex, pygments, texi2dvi) expected everything in the same directory. So I specified the directory where the org file was and everything worked. Note that depending on your tool chain, you might or might not have the same problem. I would suggest that you shut down your emacs and restart it, then try again: it may be that your session is curdled somehow.

The problem I am reporting is reproducible after a shut down of Emacs, and on any *.org file. What would be the steps to troubleshoot? #+EXPORT_FILE_NAME: works fine in standalone. In the unlikely case ~ in its argument interferes, I replaced it by the value of $HOME.

@Erwann - Now you posted a picture, I remember I had once such behaviour - what I did I made a hex-dump hexdump -c filename.org > filename-dump.txt and noticed the first three characters were unusual, starting with .. So if this is your case, either delete the first line and re-insert it, or just start a new .org file and copy just the content of your  original one (I presumed I made a wrong typing, so I do not remember exactly how I solved). Maybe it will be useful to report it as bug. Depending on your system, the command may by dump (linux) - I do not use Win.

@Ian here's the dump. It don't see leading unusual characters.

I see. That was my case. However does not hurt to delete the first line and type it again.

@Ian how was it your case after your said "3 characters unusual"?! On the first line C-k #+TITLE: XYZ turns from green to purple starting from :. C-c C-e t u returns a similar error: "Wrong type argument: listp, #("XYZ" 0 3 (:parent (#0)))". Reproducible on a new file as well.

@Erwann, in my case after deleting them the syntax highlighting was the correct one - I did not dully noted that behaviour, not recorded the characters. Note you may try the hexdump with -C flag to see if you have same result. Try also changing the theme.

@Erwann Exporting with the file content from above works here without producing any error. Maybe recompile org (once had a strange error until I recompiled it), in my case: (byte-recompile-directory "~/.emacs/elpa/org-plus-contrib-20191111" nil t)

@Erwann and of course to get more context about the error (backtrace) use M-x toggle-debug-on-error and export again. Then you will see which function causes the error (only works if it signals an error, not if it is just a warning). Would be good to add this to the question.

same error reported here, no answer unfortunately: https://stackoverflow.com/q/43730192/1365754

More with same error: conclusion > reinstall org packages or recompile (to try out do C-u M-x org-reload). 1. https://github.com/syl20bnr/spacemacs/issues/3246#issuecomment-214707023. 2. https://emacs.stackexchange.com/questions/32747/export-from-org-mode-to-latex-doesnt-accept-the-option-title 3. https://www.reddit.com/r/emacs/comments/6jeu74/getting_error_exporting_org_doc_because_it_has/

org wasn't up to date as of today. That solved the problem: M-x list-package RET U x.


text:
Why can't I list the contents of Desktop on macos using dired?
When I do C-x C-f on ~/Desktop/ in macos Catalina, I get the following error.
Listing directory failed but 'access-file' worked

I can list the directory for just ~.
I'm new to Emacs and know little else. I've tried installing Emacs through Homebrew and using a binary from https://emacsformacosx.com
I've also searched for that error where some people said there's an issue with ls on mac, but I don't have any problem listing the contents of ~. Also, I didn't find any clear solution to that problem (I tried copy pasting answers to my init file but that didn't solve anything).

Welcome to emacs.SE! Can you ls ~/Desktop from a terminal?

i can ls ~/Desktop, but first a popup appeared asking for permission

I found this: https://stackoverflow.com/questions/6192003/insecure-world-writable-dir-users-username-in-path-mode-040777-when-running-ru/6196644
And took the advice to take away write permission from my home folder: (from /Users): chmod go-w myusername

I found it. Apparently dired can't access icloud directories. My Desktop and Documents folders are sync'ed with icloud.
http://emacs.1067599.n8.nabble.com/iCloud-directory-access-issue-on-macOS-Catalina-td499227.html
If anyone comes here curious as to how they can access Desktop, Documents, or Downloads, the answer is in the link above, for reference, but I'll put it here in case that link expires.

In System Preferences -> Security & Privacy, select the Privacy tab.
From the list on the left, select Full Disk Access.
Click the padlock in the lower left of the window to unlock this setting, if necessary.
Click the + button to add Emacs to the list, then add Emacs.

Note: If it's already checked, try unchecking, allowing it to quit and restart emacs, then check it, and allow it to quit and restart emacs again.

Updating this answer since my original instructions aren't enough anymore. I had to also add ruby as others have pointed out in their answers.

Click the + button to add /usr/bin/ruby, but the usr folder is hidden in the UI it pops up, so press Shift+Command+G to popup a thing where you can type in /usr/bin, and then select the ruby program.

Can you get to them using a remote-file name? Can you get to it with Tramp, otherwise than using Dired? If so then try the same (remote-file name) with Dired.

Does it help if you customize the variable dired-use-ls-dired? Try setting to nil.

i haven't any clue what the remote file name is for my Desktop. i don't know what Tramp is either. i may be able to look into it later. i used M-x set-variable and typed in nil for dired-use-ls-dired but still have the same problem

Have you tried giving ruby full disk access? See https://emacs.stackexchange.com/questions/53026/how-to-restore-file-system-access-in-macos-catalina

i haven't tried giving ruby full access. my question was simply "why" i couldn't access my Desktop, which i found the answer to. i've marked it as the answer. now as to "how" i can access it, the answer is in the link in my answer. i've tried it just now and it works!

Cmd+O doesn't really do anything for me in Emacs, but in the GNU Emacs home buffer there is an Open a File action where it says "To start…" And it seems to be creating a file so just give it a test name and hit Save. Then dired starts working again.

Cmd+O actually refers to s-u bound to ns-open-file-using-panel, if you didn't tweak your bindings. For those tilting your head on that one, use M-x ns-open-file-using-panel instead.

Note this is not related to iCloud - all macOS users will need to give Full Disk Access to access ~/Documents, ~/Desktop and ~/Downloads and some other directories under ~

If you find the problem persists after granting Emacs full disk access:
from here on the problem remains because Emacs on MacOS gets launched indirectly, from a Ruby script. Your Emacs binary has full disk access, but Ruby does not.
One way to get around this is to get the Ruby script out of the way, and replace it with a symlink to the correct binary for your platform. See
https://github.com/caldwell/build-emacs/issues/84#issuecomment-545754668
for an example.

I was having trouble with auto-complete in C-x C-f even after granting Emacs full-disk access.  I liked this proposal about the Ruby script being the problem, but I didn't like having to make the symlink, and remember to do that every time I updated Emacs.  I just granted Ruby full-disk access so it's more permanent, if a little more insecure. It's a little more complicated to get to /usr inside the standard Open dialog (to add Ruby), but press Command-Shift-. (that's a period at the end) to see the hidden files (think of it the period as a "dot" and then think of "dot files").

At first I doubted, what was emacs doing with ruby scripts? But, then Homebrew packaging inserts those as an additional layer. Thanks.

I followed Nabi and Vinh's solutions. dired worked but not all functions. For example, the sort is not working.
A quick search leads me here: https://github.com/d12frosted/homebrew-emacs-plus/issues/383#issuecomment-899157143
The problem is that macos's built-in ls does not support several flags dired+ use. What worked for me is following instructions here:
https://stackoverflow.com/a/65112096/4062451
Notice that you might need to change the path insert-directory-program to where your brew is installed

In my case, just allow Full Disk for ruby (/usr/bin/ruby) then it works like charm!

After following Nabi's instructions my problem persists. This answer fixed it for me!


text:
How to "escape" a plain list / cannot outdent region
This is start from:
* Up
** Foo
   - x

Notice that the plain list under Foo is indented. This is what I want next:
* Up
** Foo
   - x
** Bar

But from - x, I don't know how to "escape" the plain list, in other words start a new headline. In more detail:
1:
* Up
** Foo
- x

2: Then, C-x h C-M-\:
* Up
** Foo
   - x

3: Then M-RET:
* Up
** Foo
   - x
   -

4: Then M-RIGHT:
* Up
** Foo
   - x
   -

"Cannot outdent top level regions"

Not sure I understand what you want. Are you trying to turn the list item into a headline?

No. In the example shown I am in a plain list that is indented and nested in a headline. I want to start a new headline. I can't.

Not sure that I understand correctly, but it seems to me you need C-RET (org-insert-heading-respect-content). This should create a new heading even though you are currently inside a list.

Inside a plain list, type RET, then *, then space. It's the last step I was missing. Then indent the headline as needed with M-RIGHT.

I wouldn't call this indent.  The doc says "Demote current heading by one level."


text:
How to prevent stuff from being exported
I want some stuff to be visible in the editor, but not in the export (C-c C-e). Some stuff includes headlines. I tried this:
#+EXPORT_FILE_NAME: ~/Documents/Outbox/hide
#+OPTIONS: ^:nil
#+STARTUP: indent
#+STARTUP: hideblocks
* Foo
  :DRAWER:
  - `M-x org-insert-drawer` for stuff to be hidden.
  - Unfortunately, you can't put a subtree in it, AFAIK
  - Besides, this does get exported.
  - What is meant by hidden, then?
  :END:

#+BEGIN_HIDE
You can't hide, or can you?
#+END_HIDE

And that's what I get from C-c C-e l l:
\section{Foo}
\label{sec:org2b52cc8}
\begin{itemize}
\item `M-x org-insert-drawer` for stuff to be hidden.
\item Unfortunately, you can't put a subtree in it, AFAIK
\item Besides, this does get exported.
\item What is meant by hidden, then?
\end{itemize}

\begin{HIDE}
You can't hide, or can you?
\end{HIDE}
\end{document}

Manual:
Drawers

Possible duplicate of Can I prevent export of an org subtree?

You can add a noexport tag to headlines, in order to avoid exporting them:
* This section is not going to be exported                              :noexport:
  The whole section (and all its subsections) is NOT going to be exported.

See the manual and look for EXCLUDE_TAGS.

You can add #+OPTIONS: d:nil in the preamble to prevent your drawer to be exported (and even all drawers). You can also customize (locally, or in your .emacs) the variable org-export-with-drawers.
It is unclear to me what is your #+BEGIN_HIDE environment, and what you intend to write in it. But both your drawer and "hide" environment could be simply replaced by headlines with the :noexport tag. I would definitely go for that solution in both cases.

or #+BEGIN_SRC text :exports none and to hide a specific drawer see https://stackoverflow.com/a/30297651/1365754