texts: How to run a custom formatting tool on save?

texts:
While there are packages that format on save, I'd like to be able to run a custom command that auto-formats a file on save.

Upon saving it runs an external process that:

Takes the buffer as stdin.
Outputs to a temporary file.

After that:

The output is used to replace the current buffer which is then saved.
Any errors from the stderr are reported as errors.
Any output from the stdout is printed as messages.

For the purpose of testing, this could be the auto-formatting command:

It converts the text to title-caps.

python -c "with open(__import__('sys').argv[-1], 'w') as fh: fh.write(__import__('sys').stdin.read().title())" -- /tmp/TEMP_FILE_FROM_EMACS.txt

... where /tmp/TEMP_FILE_FROM_EMACS.txt is a generated temp file name.

I realize this may be an involved answer. If this seems like too much hassle to answer, I'll investigate and post an answer myself, since I think it's useful to have a general function to handle this.


texts: How to call a function that is the value of a variable?

texts:
Can someone explain to me why the code below throws an error (void-function fn)?
(let ((lexical-binding t)
      (fn (lambda (y) (+ y 4)))
      (x 4))
  (pcase x
    (10 (- x 2))
    (4 (fn x))))

and is there a way to fix it without defun'ing a function?


texts: Equivalent of query-replace-regexp for multiple regexps

texts:
How can I do the equivalent of query-replace-regexp for multiple regexps?
For instance, if regexp1 is matched, it should be replaced by text1, and if regexp2 is matched, it should be replaced by text2 (with interactive confirmation as with query-replace-regexp). The search and replace needs to be done in one pass for all the regexps (I don't want to use query-replace-regexp on the first regexp, then on the second regexp, and so on).
While querying could be done with a single regexp like regexp1\|regexp2, I don't know how I could do the replacement depending on whether regexp1 or regexp2 is matched. When query-replace-regexp is called interactively, \, can be used to execute a Lisp expression, which could do the selection, but this is not possible for code put in my .emacs, for instance.


texts: (require 'package) is newly very slow on Windows

texts:
In recent weeks, (require 'package) takes minutes.  This only happens on Windows, not on macOS or GNU/Linux.  What is going on?  emacs-version is GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-11-15.

Resolution (see below):  It turned out not to be a problem with Emacs at all.


texts: How do I change the color of the menu bar in terminal Emacs?

texts:
I am using Emacs in a terminal. This is what the menu bar looks like:

The menu bar has a white foreground and a black background. I want a green background with a pink foreground instead. Is there a way to do this?
(Emacs version: GNU Emacs 25.2.2)


texts:
I try to set a new hex-color to highlight the current line in the distinguished theme, but this can have no effects. I put this in init.el:

;;highlight current LINE
(global-hl-line-mode 1)
(set-face-background 'hl-line "#47310D")
(set-face-foreground 'highlight nil)

How can i change the color of the current line?


texts: Set default-directory relative to the place an Elisp function is defined

texts:
I have some custom elisp functions that need to run shell scripts using shell-command. I would like to use a relative path to the script, e.g.:

(shell-command "./run.sh")

rather than an absolute one:

(shell-command "~/blah/blah/blah/run.sh")

But the relative path will only work if the working directory contains the script. I don't want to use an absolute path, because the path to the shell script might change. However, the shell script will always be in the same directory as the .el file where the function is defined, so I thought I could leverage that fact, and use a relative path instead, I just can't figure out how to do it. I know that I can change the default-directory, but I don't know how to do that without using an absolute path.

Is there a way for me to tell the function to use the directory that contains its .el file as the default-directory, or is there maybe a better solution?


texts:
When you have many buffers opened, they are all shown in the buffer list.

Are they shown in the order of visit, from the latest to the remotest?

Can we organize the buffers in the buffer list somehow? For example resort them by their pathnames?


texts: Wrong numbering of sections - html export - org-mode - RTL languages

texts:
This small example:

#+LANGUAGE: ar
#+HTML:

*  1

**  - 1. 1

**  - 1. 2 !

**  - 1. 3 !

* 2

** - 2. 1 !

** - 2. 2

** - 2. 3 !

The html-export of org-mode looks like this:

It writes correctly: from right to left (rtl language: arabic).

The problem is at the 2nd and 3rd subsection of section 1.
And at the 1st and 3rd subsection of section 2.

For example: at the 2nd subsection of the 1st section:

We should see at the beginning (that's on the right!) of the line the 1 then the 2.
But as you can see in the picture: the numbering is 2 and then 1.
(Same problem by 1.3., 2.1 and 2.3)

Also from the picture we see: There isn't a problem in the order of the numbering of "1. 2." [notice the space after the dot].  Somehow "1.2" [without space] is interpreted as an LTR-word (?)

Should I add something else in the header of the org file?
Or should i change the resulted html file?

This is from it:

1.1. - 1. 1

1.2. - 1. 2 !

1.3. - 1. 3 !


texts: Why is my minibuffer scrolling and preventing me from seeing emacs asking me questions?

texts:
My new emacs is scrolling minibuffer text so that I can't see simple stuff, like when emacs asks if I want to save changes to a file before exiting.

Doing this both in a mac window or in Terminal.

Using emacs 25.0.50, built for mac using homebrew. Installed ember-mode and elpa for packages, but that's about it.

Haven't found help via google or SO ... perhaps my search-fu is weak today. Any advice out there on how to debug / fix?


texts:
Is it possible to have several plots related to one Org table? I have noticed that

#+plot: ... file:"file1.png"
#+plot: ... file:"file2.png"
#+plot: ... file:"file3.png"
.
.
.
|col1|...|colN|
|....         |

doesn't really work. It looks like only the last #+plot: directive is considered. Of course, I could write a gnuplot script which is called once and will plot to all those files, but i would prefer to keep it as several distinct plot directives for the reasons of improved readability and a degree of automatism offered by the #+plot: directive.


texts: How to prevent emacs from converting short form quote ( ' ) to literal "quote" in custom set variables, etc?

texts:
I usually use Emacs 27.1, but on a particular remote machine, it has Emacs 26.3 installed instead. After cloning my dotfiles repository onto this remote machine, all of the "custom set variables" that Emacs automatically sets for me in init.el have the literal word "quote" instead of the quote symbol ( ' ) that I have on my usual machine.
This is leading to git thinking that my init.el files have been modified when they really haven't changed. What is a good fix for this? Would shifting these custom set variables to another location help, or can I suppress this changing of quote symbol to the literal word "quote"?
Before
(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.
 '(custom-safe-themes
     '("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default))
   '(org-agenda-custom-commands
     '(("n" "Agenda and all TODOs"
......

After:
(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.
 '(custom-safe-themes
   (quote
    ("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default)))
 '(org-agenda-custom-commands
   (quote
    (("n" "Agenda and all TODOs"
......


texts: I would like to typeset bilingual (English, Hindi) in emacs .org mode using mangal font available on windows . It has to be exported using xelatex. Kindly explain step by step setup for the same . I would be obliged


texts:
So I'm entirely new to programming but I have been trying to familiarize myself with emacs for future scripting. When I am typing in the scratch buffer, I type certain functions such as defun and while and they are recognized by the buffer and appear in purple. However, with other Lisp functions such as set or +, they do not appear in any color and I was wondering why that is.

Thanks


texts: Changing AUCTeX viewer results in errors claiming TeX-engine is wrongly set, although it is set correctly

texts:
This question was completely rewritten, see the previous version.

I have this XeLaTeX file:

\documentclass{article}
\usepackage{fontspec}

\begin{document}
\thispagestyle{empty}
\pagestyle{empty}

äätewää--llll
\end{document}

which produces the (intended) image when compiled with C-c C-a:

my init.el used for that is:

(require 'package)
(dolist (source '(("marmalade" . "http://marmalade-repo.org/packages/")
                  ("melpa" . "http://melpa.milkbox.net/packages/")
                  ))
  (add-to-list 'package-archives source t))
(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))
(defvar tmtxt/packages
  '( auctex))
(dolist (p tmtxt/packages)
  (when (not (package-installed-p p))
    (package-install p)))

(setq-default TeX-engine 'xetex)
(setq-default TeX-PDF-mode t)

all the above is expected so far

However, if i change my init.el to use a different viewer (latex-preview-pane-mode):

(require 'package)
(dolist (source '(("marmalade" . "http://marmalade-repo.org/packages/")
                  ("melpa" . "http://melpa.milkbox.net/packages/")
                  ))
  (add-to-list 'package-archives source t))
(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))
(defvar tmtxt/packages
  '( auctex))
(dolist (p tmtxt/packages)
  (when (not (package-installed-p p))
    (package-install p)))

(setq-default TeX-engine 'xetex)
(setq-default TeX-PDF-mode t)

(custom-set-variables
 '(TeX-view-program-list
   (quote (("preview-pane-mode" latex-preview-pane-mode))))

 '(TeX-view-program-selection
   (quote
    (((output-dvi has-no-display-manager)
      "dvi2tty")
     ((output-dvi style-pstricks)
      "dvips and gv")
     (output-dvi "xdvi")
     (engine-omega "Atril")
     (output-pdf "preview-pane-mode")
     (output-html "xdg-open"))))
)

i receive with the same XeLaTeX source as above the following error:

!...............................................
! For immediate help type H <return>.
!
! See the fontspec documentation for further information.
!
! instead of plain "latex" or "pdflatex".
! You must change your typesetting engine to, e.g., "xelatex" or "lualatex"
!
! The fontspec package requires either XeTeX or LuaTeX to function.
!
! Fatal fontspec error: "cannot-use-pdftex"
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


texts: make local map bindings available through a global prefix

texts:
I am trying to set up something like Spacemacs, but fully under my control.  I have already created a tree of my own keymaps with global commands, and it is available on M-SPC.  But now I'd like to also make available local bindings for major modes, those that typically start with C-c, through the same prefix M-SPC, but without the C-c.

Clearly I cannot just get the part of the local map after C-c and graft it onto my M-SPC tree - it would have to be a function that looks up the binding on the fly.  But how to read the key sequence? read-key-sequence only works on "active" maps according to the doc - indeed it has to because it has no keymap argument.  But the keymap I need to consult when reading the keys is not active, it is the sub-keymap of the local map after C-c.  So I seem to be stuck.


texts: How to properly use VARIABLE-TAG in Wisent?

texts:
I try to get around Wisent/Semantic and I'm playing with toy languages at this point. Issue I'm stuck with is how to mark multiple variable declarations.

My toy language has only WORD terminal and all terminals should get VARIABLE-TAG. I tried this:

%token WORD
%start words

words : word
      | words word
        (append $1 (list $2))
      ;

word : WORD
        (VARIABLE-TAG $1 nil nil)
     ;

The above seems to mark only first word as variable. How to properly use VARIABLE-TAG so that all words are marked as variables?


texts: Emacs - elisp code autocompletion in emacs-lisp-mode

texts:
With below setup, my ielm mode has autocompletion function:

(require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
   '(add-to-list 'ac-modes 'slime-repl-mode 'emacs-lisp-mode))

(defun ielm-auto-complete ()
  "Enables `auto-complete' support in \\[ielm]."
  (setq ac-sources '(ac-source-functions
                     ac-source-variables
                     ac-source-features
                     ac-source-symbols
                     ac-source-words-in-same-mode-buffers))
  (add-to-list 'ac-modes 'inferior-emacs-lisp-mode)
  (auto-complete-mode 1))
(add-hook 'ielm-mode-hook 'ielm-auto-complete)

(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook (lambda () (set (make-local-variable 'company-backends) '(company-elisp))))

(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'emacs-lisp-mode-hook (lambda () (set (make-local-variable 'company-backends) '(company-elisp))))

But it doesn't work when edit a .el file. I guess I can not share the same function call ielm-auto-complete but don't know how to change it.


texts: "Invalid face reference: linum" even load linum after make frame

texts:
I want to have line number at buffer, but when I use Emacs server, the Message buffer display the following error:

Invalid face reference: font-lock-comment-delimiter-face [2 times]
Invalid face reference: linum
Invalid face reference: font-lock-comment-face
Invalid face reference: font-lock-comment-delimiter-face
Invalid face reference: font-lock-comment-face
Invalid face reference: font-lock-comment-delimiter-face
Invalid face reference: font-lock-comment-face

So I found out linum is designed to use after frame is created. So I add such hook in my .emacs file

(defun my-turn-on-linum-mode (frame)
  "My function to turn on linum mode."
  (with-selected-frame frame
    (linum-mode 1)))

(if (daemonp)
    (progn
      (add-hook 'after-make-frame-functions 'my-turn-on-linum-mode))
  (global-linum-mode 1)) ;;; if not daemon, just do it

Then if I start with emacs --daemon and open clients, it works fine for the first client I open, either graphic or terminal mode. It also works good no matter how many times when I open graphic frames. However, if I open client in terminal mode for the second time, the same error emergences. The error continues to show up if I open client in terminal mode further.

I'm really frustrated after 10 hours' digging. Maybe I should learn Lisp seriously? Any suggestions are appreciated!


texts: Emacs python can not update imported files?

texts:
I am using spacemacs, anaconda-mode.

In file main.py, I imported a class from file a.py. Then I pressed C-c C-p to launch an ipython shell, and run main.py, everything is OK. But then I modified the class in a.py, and save, and rerun main.py, I found that the class in a.py was the previous version, which means ipython did not update the content in a.py! Only when I killed the python buffer, and relaunched the ipython shell, did the content in a.py be updated.

I tested this in Spyder, which is a python IDE, and it worked perfect as I expected. But what's wrong with emacs? Are there some configurations that I missed?


texts: export latex symbol in src block org mode to latex and html

texts:
I'm writing some pseudo code having some symbols like λ (\lambda). Enabling org-toggle-pretty-entities converts \lambda to λ in buffer, however when I export to HTML or latex, they are not converted. How can I use these symbols in src block.

I'm okay with using example, verse block or any other way of preserving newlines.


texts: Preventing convertion of ASCII rules on org--html export

texts: When you export to html, -- is converted to en-rule and --- to em-rule.  Is it possible to prevent this?


texts: Sharing *compilation* window with other compilation-like commands

texts:
Is it possible to make a few different commands share a window for their output? For example, let's say I do M-x compile and get a *compilation* buffer in bottom half of my frame. If I then do M-x ack (or M-x grep, etc.), I would like the results of these commands to be displayed in the same window which *compilation* occupies.

Some background: In reply to this question @Francesco provided a nice snippet which displays the compilation window at the bottom of the current frame. This works nicely to manage *compilation*, but it would be even nicer if compile, ack, ag, igrep and a few similar commands shared this window.

(So what I am really looking for is how to extend Francesco's snippet to manage the output of multiple commands together.)


texts: Get verbatim output of 'curl wttr.in' in org src code

texts:
I want to record the weather info within org with commands

#+BEGIN_SRC shell :results output
curl wttr.in/place
#+END_SRC

#+RESULTS:
#+begin_example
Weather report: place

 [38;5;226m    \   /    [0m Clear
 [38;5;226m     .-.     [0m [38;5;047m7[0m °C[0m
 [38;5;226m  ― (   ) ―  [0m [1m↑[0m [38;5;046m0[0m km/h[0m
 [38;5;226m     `-’     [0m 10 km[0m
 [38;5;226m    /   \    [0m 0.0 mm[0m

The gibberish get outputted however,

How could get it display as 'curl wttr.in' work on terminal ?


texts: org-mode: How to change cursor type for variable-pitch mode?

texts:
I have the following block of lisp codes in my .emacs config to enable variable-pitch mode for Org-mode. It is working fine however the cursor has changed from the default block to a thin line. Could someone please advise how or what I can add into the function below to change cursor-type back to box?

(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.
 '(fixed-pitch ((t (:height 130 :family "Consolas"))))
 '(org-code ((t (:foreground "DarkOrange1"))))
 '(variable-pitch ((t (:height 130 :family "Helvetica Neue LT Std")))))

;; Set variable-pitch for org buffer, except org-table/code/block
(defun set-buffer-variable-pitch ()
  (interactive)
  (variable-pitch-mode t)
  (setq cursor-type 'box)
  (setq line-spacing 3)
   (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
   (set-face-attribute 'org-code nil :inherit 'fixed-pitch)
   (set-face-attribute 'org-block nil :inherit 'fixed-pitch)
   (set-face-attribute 'org-block-background nil :inherit 'fixed-pitch)
  )
(add-hook 'org-mode-hook 'set-buffer-variable-pitch)

Thank you in advance.


texts: Are there Emacs tools for the visually-impaired?

texts:
I have a client, a Ph.D. candidate in Computational Chemistry, that is visually impaired. He's pretty self sufficient and he's had some success learning the content by directly reading source, when available, for most texts. He does this to read the LaTeX, when used, in order to understand the math.

He's also trying to learn Python, which relies on indentation to identify code blocks. I've helped him hack the python mode to trigger system alerts every time he uses auto-indent, and this seems to work ok for now.

He works on a windows client to access a unix server for his computation. Generally his Emacs is running on the server and he's accessing it through X-forwarding.

I've come across Emacspeak, but it appears to target linux boxes. There are a variety of text-to-speech tools for the Windows platform, and I think his preference is to use JAWS. These tools are helpful, but they can complicate the process when they compete with native teach-to-speech features of various applications.

Besides Emacspeak, are there other tools or techniques for efficiently using Emacs if you're visually impaired? Are there essential details I need to know about Emacspeak in order to benefit from it?


texts: Importing HTML (orgmode-like) document with inline images to orgmode

texts:
I often find myself wanting to save local copies of sites such as:

http://ase.tufts.edu/gsc/gradresources/guidetomixedmodelsinr/mixed%20model%20guide.html

I need to store a local copy of it (to read in my favourite editor). One solution of course is to use eww, but I would like to be able to port it through to Orgmode syntax so I can annotate it. I tried Pandoc, but couldn't seem to get the right filters. I end up with either no whitespace; or hundreds of html src blocks.

Any solutions would be appreciate. Inline images are a must (or at least saved).


texts: How can I whitelist a file or directory that is in my .gitignore?

texts:
In my Clojure projects, I like to keep my REPL namespace separate from my other source files, so I always have something like this in my project.clj:

:profiles {:dev {:source-paths ["dev"]
                 :repl-options {:init-ns user}}}

Since I only use that file (and its parent directory) for temporary definitions and experimentation and such, I don't want it in version control, so I put the whole directory in my .gitignore:

/dev/

So my project structure looks something like this:

myproject
├── dev
│   └── user.clj
├── .gitignore
├── project.clj
└── ...

Now, for the most part, Projectile works great for navigating around projects; I can use C-c p f to quickly switch to my source files, tests, documentation, project.clj, .gitignore, etc.

But I can't switch to my REPL namespace file! I tried adding a .projectile file to my project and playing around with that, but as far as I can tell, if a file is in .gitignore, there is no way to tell Projectile not to ignore it.

So my question is, is it possible to ignore a file or directory in Git but not in Projectile?


texts: How can I detect if the current character is a comment character for that major mode?

texts:
I am working on this little function that pulls up the next line to the current line. I want to add a functionality so that if the current line is a line comment and the next line is also a line comment, then the comment characters are removed after the "pull-up" action.

Example:

Before

;; comment 1▮
;; comment 2

Calling M-x modi/pull-up-line

After

;; comment 1▮comment 2

Note that the ;; characters are removed that were before comment 2.

(defun modi/pull-up-line ()
  "Join the following line onto the current one (analogous to `C-e', `C-d') or
`C-u M-^' or `C-u M-x join-line'.

If the current line is a comment and the pulled-up line is also a comment,
remove the comment characters from that line."
  (interactive)
  (join-line -1)
  ;; If the current line is a comment
  (when (nth 4 (syntax-ppss))
    ;; Remove the comment prefix chars from the pulled-up line if present
    (save-excursion
      (forward-char)
      (while (looking-at "/\\|;\\|#")
        (delete-forward-char 1))
      (when (looking-at "\\s-")
        (delete-forward-char 1)))))

The above function works but for now, regardless of the major-mode, it will consider / or ; or # as a comment character: (looking-at "/\\|;\\|#").

I'd like to make this line more intelligent; major-mode specific.

Solution

Thanks to @ericstokes' solution, I believe that the below now covers all my use cases :)

(defun modi/pull-up-line ()
  "Join the following line onto the current one (analogous to `C-e', `C-d') or
`C-u M-^' or `C-u M-x join-line'.

If the current line is a comment and the pulled-up line is also a comment,
remove the comment characters from that line."
  (interactive)
  (join-line -1)
  ;; If the current line is a comment
  (when (nth 4 (syntax-ppss))
    ;; Remove the comment prefix chars from the pulled-up line if present
    (save-excursion
      (forward-char)
      ;; Delete all comment-start or space characters
      (while (looking-at (concat "\\s<" ; comment-start char as per syntax table
                                 "\\|" (substring comment-start 0 1) ; first char of `comment-start'
                                 "\\|" "\\s-")) ; extra spaces
        (delete-forward-char 1)))))


texts: Is it possible to apply `smerge-keep-mine` for all the conflicts by using a single keybinding?

texts:
I am using smerge to resolve conflicts in order to apply merge. I am applying one by one for smerge-keep-mine to all conflicts, which I belive equivalent for git merge --strategy-option ours
[Q] Is it possible to apply smerge-keep-mine for all the conflicts by using a single keybinding?
config:
(defun smerge-try-smerge ()
  (save-excursion
    (goto-char (point-min))
    (when (re-search-forward "^<<<<<<< " nil t)
      (require 'smerge-mode)
      (smerge-mode 1))))
(add-hook 'find-file-hook 'smerge-try-smerge t)
(add-hook 'after-revert-hook 'smerge-try-smerge t)

(defun smerge-next-safe ()
    "returns t on success, nil otherwise"
  (condition-case err
      (not (smerge-next))
    ('error
     nil)))

(require 'vc)
(defun next-conflict ()  ;; key-binding
  (interactive)
  (let ((buffer (current-buffer)))
    (when (not (smerge-next-safe))
      (vc-find-conflicted-file)
      (if (eq buffer (current-buffer))
          (message "No conflicts found")
        (goto-char 0)
        (smerge-next-safe)))))

;; smerge-keep-current bound to smerge-command-prefix (RET) to keep the version the cursor is on.
;; smerge-keep-mine bound to smerge-command-prefix (m) to keep your changes.
;; smerge-keep-other bound to smerge-command-prefix (o) to keep other changes.


texts: Org-mode property to make subtree visibility bimodal?

texts:
Is there a property I can set on a headline that makes Tab / (org-cycle) show everything in the subtree (i.e., effectively call (outline-show-subtree))?

Whereas subtree cycling rotates a subtree among the three states, FOLDED, CHILDREN, and SUBTREE, I would like to limit the state space to just FOLDED and SUBTREE for select subtrees. This mechanism implicitly indicates that a particular subtree is meant to be viewed as an atomic unit, which is helpful for incorporating complete documents within an Org-mode tree. I find the alternative somewhat distracting—i.e., identifying the right subtree to expand, hitting Tab twice, and visually confirming whether I'm in the right location.


texts:
I use evil. Normally, when I commit, I'd like to immediately start typing, but evil starts the buffer in evil-normal-state. I used to set

(evil-set-initial-state #'git-commit-mode 'insert)

But that no longer works, as Magit uses text-mode for its commit buffers.

How can I have Magit commits default to evil-insert-state?


texts: How to add picture before a title in HTML exported by OrgMode

texts:
I am writing an article in org mode to be exported to HTML for being published on the web. By looking at the documentation, I have not been able to find
a way to insert an image before the title of the article.
So for instance, I would like my page to look like this (the black border indicates the computer screen)

How do I do this? Do I add some header information? Currently my header in the org file looks like this.
#+TITLE: Hello World
#+AUTHOR: A.U.Thor
#+EMAIL:  hello.world@NOSPAM.outlook.com

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css" />
#+OPTIONS: num:nil

Maybe the solution to this is to use CSS, by specifying that a certain figure element comes before the title? I am not very good at CSS but this is my best guess. Maybe the ORG guys have already developed some native (and easily remembered) syntax for this?


texts:
I test the following procedure from org-mode

#+name: case-2.1.1-factorial.el
#+BEGIN_SRC elisp
(defun factorial(n)
  (if (= n 1)
      1
      (* n (factorial (- n 1)))))
(trace-function #'factorial)
(factorial 4)
#+END_SRC

#+RESULTS: case-2.1.1-factorial.el
: 24

trace-function does not work as expected as from shell

1 -> (factorial 4)
| 2 -> (factorial 3)
| | 3 -> (factorial 2)
| | | 4 -> (factorial 1)
| | | 4 <- factorial: 1
| | 3 <- factorial: 2
| 2 <- factorial: 6
1 <- factorial: 24

How could make 'trace-function' print the above tracing from org-mode.


texts:
It's time.  I've spent too long with too many pieces of elisp lying around in site-lisp, outdated until I manually grab a new copy.  I am new to the ELPA/MELPA/package.el/el-get world, but have determined (okay, maybe 90% confident) from emacswiki and this excellent question that MELPA is the way to go, but how, exactly do I do that?  There are some basic instructions for initial setup on the website, but it's not clear to me how I should migrate, and tell emacs:

Which pieces to check on
Where and how to store them
What to do with my local copies


texts: How can I prevent company-mode completing non-English chars?

texts:
i tried these codes before,
but none of them works for me .
how can i edit this to achieve my goal.


texts: Some lisp errors not showing a backtrace

texts:
I have a few custom written methods in my init file.
They run in to null issues - too often :)

Anywhen, I noticed for some errors emacs pull up a backtrace/debugger prompt for me. But often the error is shown in the minibuffer only. But its hard to troubleshoot should because there's no backtrace so the user doesn't know where to look.

Is there a toggle I'm missing to tell emacs, hey bring up a (debug) prompt when an/any error happens.


texts: I am using spacemacs. When enabling highlight-indentation-mode in python-mode, I found that the vertical lines are not continue, they will be interrupted if there is an empty line. How can I fix this?


texts: How to use elpy and non-python autocomplete

texts:
Elpy provides company-mode to handle autocompletion. The way it is set up, company only turns on when I am in something handled by Elpy.

If I enable auto-complete it works in non-python files, but then both company and auto-complete pop up, which is not desired behavior.

How can I enable company to still work within Elpy, but turn on auto-complete to be on elsewhere, and not clobber company?


texts: Changing the default-directory of an open compilation buffer

texts:
I have two different compile commands, and they need to run in different directories.

I've gone through the trouble of making sure that if at all possible, I re-use the open compile buffer, rather than open a new view to it over and over again. The problem is that the default-directory of the buffer is set after I run one command, and subsequent calls don't seem to be able to override the default directory.

So:

(defun build-engine ()
  "Build the exe."
  (interactive)
  (let ((default-directory "f:/Projects/build/"))
    (compile "build.pl -target=release_fastbuild -platform=win64 %*")))

(defun build-test (name)
  "Build a test from the current tool executable with the specified name"
  (interactive "sMap Name: ")
  (let ((default-directory "f:/Projects/bin/"))
    (compile (concat "tool_win64.exe /genfastload:PC /name:" name))))

Those are the two compile commands.

This is how I always switch to the open compile buffer, so I don't keep opening new ones. (It's also how I keep the buffer from vertically splitting.)

(defadvice compile (around split-vertically activate)
  (if (and (get-buffer "*compilation*")
           (not (eq (current-buffer) (get-buffer "*compilation*"))))
      (switch-to-buffer-other-frame (get-buffer "*compilation*"))
    (let ((split-width-threshold 9999)
          (split-height-threshold 0))))
    ad-do-it)

If I run the first build command, it works. Then if I build the second, it fails because the default-directory is still set to f:/Projects/build/. If I kill the first compile buffer, my command works.

I could write some infrastructure so that the build-engine command only uses build buffers and the build-test command only uses test buffers, but it seems like that let should override the previous one, shouldn't it?


texts: Org table spreadsheet recalculate all TBLFM lines

texts:
The following answer states, that one must have all recalculating formulas in one #+TBLFM line: https://emacs.stackexchange.com/a/10946/10090. Indeed, when I try the following formulas only the first is recalculated automatically:

|   | Runde | 0 | 1 | 2 | 3 | Resultat |          % |
|---+-------+---+---+---+---+----------+------------|
| ! | name  |   |   |   |   |   result | percentage |
| # | Alice | 1 | 1 | 0 |   |        2 |      66.67 |
| # | Bob   | 0 | 0 | 1 |   |        1 |      33.33 |
#+TBLFM: $7='(+ $<<<..$>>>);N
#+TBLFM: $8='(format "%2.2f" (* (/ 100 (float (+ @3$result..@4$result))) $result));N

When I put them both in one #+TBLFM line as in the following example, it will recalculate both formulas as intended.

|   | Runde | 0 | 1 | 2 | 3 | Resultat |          % |
|---+-------+---+---+---+---+----------+------------|
| ! | name  |   |   |   |   |   result | percentage |
| # | Alice | 1 | 1 | 0 |   |        2 |      66.67 |
| # | Bob   | 0 | 0 | 1 |   |        1 |      33.33 |
#+TBLFM: $7='(+ $<<<..$>>>);N::$8='(format "%2.2f" (* (/ 100 (float (+ @3$result..@4$result))) $result));N

Is there a way to change this, so that it considers the first #+TBLFM line first, then the second, then the third, and so on?
As I can already have multiple #+TBLFM lines, this would seem natural to me. The current behavior caused me some headache not understanding "why my second formula worked only sometimes".


texts: Custom function to map through nested lists sorting by time-stamp

texts:
In the following example, please assume that we are using time-to-seconds to convert each times-stamp into a decimal representation.  I have already converted the time-stamps to seconds in this example.  Each node has at least one time-stamp, but there might be more than one time-stamp per node.  The current node with corresponding time-stamp is represented by a cons cell with the cdr being t.  The time-stamps will always be unique.  The nodes are vectors with multiple elements.

  (defun goto-node (time-stamp n)
"Go to the desired node commencing from an existing TIME-STAMP.
If N is positive, then go forwards in time by that number of N time-stamps.
If N is negative, then backwards in time by that number of N time-stamps.
If node does not exist, return nil; otherwise, return node and corresponding time-stamp."

INSERT MAGIC HERE)

BEGIN WITH:

'(([node1] ((5.6) (3.7) (11.7) (8.2)))
  ([node2] ((4.4) (9.9) (6.1 . t)))
  ([node3] ((7.5) (2.3) (1.5)))
  ([node4] ((10.3))))

EXAMAPLES:

(goto-node 6.1 -1) => '([node1] (5.6))

(goto-node 6.1 -4) => '([node3] (2.3))

(goto-node 6.1 1) => '([node3] (7.5))

(goto-node 6.1 4) => '([node4] (10.3))


texts:
For a variety of reasons it's possible to end up with duplicate heading Id's (manually-set ID conflicts, copy pasta, duplicate files, etc.).

When refiling you may get a message

WARNING: 17 duplicate IDs found, check *Messages* buffer

Followed by a (possibly) long list of locations of duplicate Id's:

Duplicate ID "271b2fbe-cb4f-4eb8-86d5-91544028ccae", also in file /home/erik/data.org
Duplicate ID "bc7ea3e9-f821-4bee-9ce6-255083721a8a", also in file /home/erik/data.org
Duplicate ID "24afb249-8481-46a5-8237-06a0c22295eb", also in file /home/erik/data.org
Duplicate ID "6a545fe0-bd19-4523-8a6d-f7500a114f5f", also in file /home/erik/data.org

It's fairly simple to kill/copy the id and search through the document to replace duplicate ids, but that is rather onerous.  I'm curious what mechanisms are available in org-mode to assist in resolving these or alternatively what people may have come up with to resolve this occasional problem with their own agendas.

It looks like the duplicate logic is limited to what is currently baked into org-id-update-id-locations and would be easy to extract, but I'd like to hear some other thoughts before I write a helper.


texts: Distinct frame size for internal and external monitors

texts:
It's possible to add a line to one's .emacs

(add-to-list 'default-frame-alist '(fullscreen . maximized))

that will make make-frame-command (C-x 5 2) spawn maximized windows.

It's also possible to distinguish this customization

(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(fullscreen . fullheight))

for the initial and the default frames.

I would like the customization to be based instead on whether I'm using an external monitor.

If I'm using the laptop's built-in display, I'd like the (initial and default) frames to be maximized.
If I've connected the laptop to an external display, I'd like the (initial and default) frames to use only 60% of the width and 60% of the height.

Is this possible? How?

A solution that only works on a MacBook is welcome and sufficient for me.


texts: Adding directory local variable for projectile test command is not working

texts:
I'm setting up my python lsp using this video tutorial.
My emacs init.el configuration file is here
By default projectile-project-test-cmd runs the command python -m unittest discover. I want to change it to pytest instead as explained by tutor.
I followed the below steps -
1. M-x add-dir-local-variable RET
2. choose mode 'python-mode'
3. Add local-variable 'projectile-project-test-cmd'.
4. Add local variable value "pytest".

It creates .dir-locals.el file with below contents -
((python-mode . ((projectile-project-test-cmd . "pytest"))))

Now when I run M-x projectile-test-project it runs pytest command.
But when I close emacs and reopen it, it stops running pytest and runs python -m unittest discover instead.
How to fix this issue?


texts: LaTeX3 allows for some flexibility in specifying optional arguments to create commands and environments. For example you could specify \NewDocumentCommand{\foo}{d<>m}{...} and this would be used as \foo<something optional>{something required} -- d<> specifies an optional argument surrounded by angle brackets. What I would like to be able to do is to color the optional argument in AUCTeX in the same way that occurs with \section[something optional]{something mandatory}. Is this possible, and, if so, how accomplished? Thanks.


texts: Styling source code blocks with pygments.css in Org mode -> HTML export (Pelican)

texts:
I'm using the org-mode reader for Pelican to generate articles for my blog (Export to HTML). Code blocks in Markdown version of the article look perfect but I cannot enable Pygments for org-mode.

Is there any way to process org-mode code blocks using Pygments?

P.S I know about Pandoc but I need a more emacs-way solution to be able to customize export options using Emacs Lisp, not Haskell.


texts: How to go to the previous error in latex document

texts:
After compiling a LaTeX document with errors I can go to the first error via TeX-next-error to the second one by executing this macro again etc. After the last error pressing it once more results in no more errors. That makes sense so far. However using TeX-previous-error doesn't bring me to the previous error but to the next one. For example if I am by the second error and execute TeX-previous-error it jumps to the third error and not to the first one. In particular if TeX-next-error reached no more error, TeX-previous-error doesn't bring you to the last error.

My AucTeX version is 11.89.4

Is this a bug or an intended behavior (why?). Is there any other way to go to back and forward in the error list?


texts: How to highlight whitespace only in the active region?

texts:
I have global-whitespace-mode enabled which is configured to display TAB and SPC characters with (setq whitespace-style '(space-mark tab-mark))
How can I highlight whitespace characters only on selection?
(Selection could be a line or the entire buffer)


texts: Scripted bookmark jump not working after startup

texts:
Add the following to .spacemacs:

      (defun my-bookmark-set (char)
        (interactive "cPlease enter a bookmark name to set: ")
        (bookmark-set (char-to-string char)))

      (defun my-bookmark-jump (char)
        (interactive "cPlease enter a bookmark name to jump to: ")
        (bookmark-jump (char-to-string char)))

      (define-key evil-normal-state-map (kbd "'") 'my-bookmark-jump)
      (define-key evil-normal-state-map (kbd "m") 'my-bookmark-set)

Set a bookmark a with C-x r m a or ma, and quit and restart emacs
Navigation to bookmark a fails with "Invalid bookmark a" displayed

'a

Navigation to bookmark a succeeds

C-x r b a

Move cursor to another location
Navigation to bookmark a succeeds

'a

Why does the action at step 3. fail, when at step 6. and subsequently it succeeds?


texts:
Inside of eshell I get the error

LSOpenURLsWithRole() failed with error - 10810 for the file ...

if I try to use the open command on OS X. What's going on here and is there a workaround?

Edit: The error code was 10810 (not 100810). I also get the same error in emacs in shell, term, and ansi-term. open does work for me in iTerm2 and terminal. I've tried this on pdf and png files.


texts:
Does the cl-loop macro implement an equivalent to the continue keyword of other languages?
The behavior of break can be achieved by using until or while clauses by placing them in the middle of cl-loop, e.g.
(cl-loop item in '(1 2 3 4)
         do (print item)
         until (= 3 item)
         do (print item))

will be roughly equivalent to Python code
for item in [1, 2, 3, 4]:
    print(item)
    if item == 3:
        break
    print(item)

However, I cannot identify any clause, that says "abort this iteration step, continue with the next", like the continue keyword would do. Is there such a clause?
Usage example
Let's say I want to do something for every string in a list.  From the string I want to derive a file-name, and if it exists, collect data about those files.
With a continue clause:
(defconst mylist '(1 2 "hello" 3 "world" 4))

(defconst mylist-file-data
  (cl-loop for prefix in mylist
           unless (stringp prefix) continue
           for file-name = (concat prefix ".txt")
           unless (file-exists-p file-name) continue
           for attributes = (file-attributes file-name)
           for mtime = (file-attribute-modification-time attributes)
           for size = (file-attribute-size attributes)
           collect (list file-name mtime size)))

By contrast, without a continue clause I cannot use for clauses to define variables, that can only be defined when the condition is fulfilled. Instead I need to reformulate the loop more awkwardly, e.g. as
(defconst mylist-file-data
  (cl-loop for prefix in mylist
           for file-name = (if (stringp prefix) (concat prefix ".txt"))
           for attributes = (if (file-exists-p file-name) (file-attributes file-name))
           for mtime = (if attributes (file-attribute-modification-time attributes))
           for size = (if attributes (file-attribute-size attributes))
           if attributes
           collect (list file-name mtime size)))

Note how all (if ...)s are executed for each iteration step, even when the first already decides that the step could be skipped.


texts: how to use this-command and last-command in tests?

texts:
I have a usecase for this-command and last-command, because I'd like a double invocation of a command to behave differently (it's an indenter, FWIW).

Some manual interactive experiments suggest that invoking commands manually with M-x or key combinations set the this-command and cycle last-command, which can sometimes get confusing if the command has any kill-* behaviour in it. This is as expected.

However, when called from my ert tests, even if I invoke functions with run-interactively, this-command remains nil.

How can I make my scripted ert tests invoke commands so that this-command / last-command behave the same as when the user is entering those commands?


texts:
At work we have several different commit messages that are used for every feature branch:

branchname initial
branchname ready for review
branchname passed review
branchname done
plus a few more that apply in special situations

Is there some way to make custom magit commands to pre-populate the commit message with the relevant text? Ideally it would be possible to add more actions to the *magit-commit-popup* buffer for these types of commits.
If there's no way to add additional options in the commit popup, I'm open to other ideas. For example:

Using yasnippets to store and retrieve the commit messages (I'm aware of this answer). However, this seems sort of inelegant.
Writing elisp function(s) to call the magit internal functions with appropriate values. This might be a stretch for me, and anyway would be prone to breakage if magit changes.


texts: Org file: Change color of links if they point to a non-existing file/directory

texts:
Is it possible to have Org-mode links change color if the file/directory they're pointing to does not exist?

I use the Leuven Theme, and links are displayed in blue. I'd like links to be displayed in red if they point to a non-existing directory. In the following snippet, for example, the first link would be displayed in blue, and the second in red:

[[file+emacs:/home/user/existing][This directory exists!.]]
[[file+emacs:/home/user/nonexisting][This directory does not exist!.]]

The reason is that I have project directories where the access is shared with other users. Sometimes they rename files and my org documents end up having invalid links. I'd like to have some sort of visual feedback to detect these issues as soon as they appear.


texts: Org #+INCLUDE: turning what I want to be a 2nd level header into a 1st level header

texts:
Test case:

a.org

* This is a big section

  I have some content here

** And a second level section

   And more content here

*** And a third level section

    And more content here

b.org

** I have another second level section

   These files in my real world case are supposed to be split by date

*** You can see that

    [[In the repository][https://gitlab.com/srnb/notes]]

*** The actual real world case can be seen

    [[In the two APUSH sections][https://gitlab.com/srnb/notes/tree/master/AP%20US%20History]]

main.org

#+INCLUDE: a.org
#+INCLUDE: b.org

Resulting output when exported to HTML is that I have another second level section is a top level section.

Real world case: GitLab/srnb/notes@master/AP US History

Real world output: m.s5.pm/notes/AP US History

The second file, 2019-08-20-NeoEuropean-Colonies.org, is the one with the second level header.

The script that generates the big Org files with all the includes is .deploy.sh in the repository's root; it can be run locally.


texts: Evil text objects on kebab-case behave differently on dw and cw

texts:
I would like my evil text objects to work on kebab-case words, so that dw or cw act on the "whole-kebab-word" and not just on "whole".

Therefor I have put (modify-syntax-entry ?- "w" clojure-mode-syntax-table) into the clojure-mode-hook in my .spacemacs.

Now dw works on the whole kebab-word, but cw does not. It changes only the first part. Why is that?


texts: How to set key binding for read-only-mode? in order to simplify cursor movement

texts:
moving point command: next-line, previous-line, forward-char, backward-char, etc.

How to omit Ctrl key in read-only-mode?

How can I combine with read-only-mode-hook to automatically enable keybind when opening a file with read-only permissions?


texts:
Org-agenda has been working well all week. Now that it is Sunday, C-c a a produces an agenda that displays Monday 18 November through Saturday 23 of November.

I've changed some of the relevant parameters as below

(setq org-agenda-span 10)
(setq org-agenda-start-day "-3d")

or

(setq org-agenda-start-day "-1d")
(setq org-agenda-span 5)
(setq org-agenda-start-on-weekday nil)

But it hasn't gotten the agenda to display days beyond Saturday the 23rd of Nov.


texts: Can't run org-refile function in Spacemacs

texts:
I am using GNU Emacs 27.1 with Spacemacs 0.300. I am new to Emacs and Org-mode. I want to use the function org-refile with the shortcut C-c C-w. However, this is what I get:

Why can't I use that function?
Besides, do you recommend using Spacemacs or Vanilla Emacs for someone who is learning?
Thanks in advanced!
EDIT
The issue had something to do with Spacemacs and its key bindings. I ended up switching to Vanilla Emacs. Since I am just starting with Emacs, I feel more in control than with Spacemacs.


texts: xterm-mouse-mode inserting cursor information on drag

texts:
I'm running into a problem with emacs used via ssh. The problem occurs when I:

Log in remotely using SSH on Konsole
Run emacs -Q
Invoke mouse mode with M-x xterm-mouse-mode

When I click-and-drag on the frame, information about the position of the cursor is inserted. Click-and-dragging around the top of the screen results in text of the form
[<0;38;2M[<0;39;2M[<0;39;2m...
being inserted into the document. Text is inserted at the current selection, and appears as the mouse moves.
From playing around, it looks like this is information about the position of the cursor. The format is [<(line number);(column number);(something else).
I'm using Konsole, connecting via SSH. My computer is running Ubuntu 20.10. The remote system I'm logging into is running Ubuntu 16.04. I would like dragging the mouse to select text, not insert text. How can I achieve this?


texts: How to exclude a company-backend from autocompleting without globally removing it

texts:
I would like to be able to prevent company mode from automatically suggesting a specific backend (namely company-dabbrev) when in a specific mode (using text-mode-hook), however I don't want want to remove this backend from company-backends as I still want to include to get its completions when I manually invoke company-complete-common-or-cycle.

So, how would I go about excluding a backend from autocompleting on text input without excluding it entirely from company-backends?

(The motivation for this is that I find autocompletion on arbitrary words I'm typing in a text document distracting, but I do want to keep autocompletions such as latex environments, as these are quite handy. I do however sometimes want manual autocompletion for when I'm typing a long word that I've forgotten how to spell, but I know I've typed before.)


texts: Tramp hangs on 'Sending password' whenever ESS is active

texts:
Tramp has been hanging on 'Sending password' for me whenever I try to use it. This includes the simplest test case of C-x C-f /sudo::/etc/hosts.

After some trial-and-error with my .emacs, it looks like the problem occurs if and only if ESS is active. Unfortunately, I haven't been able to figure out anything more than that. Debug log output from trying to do /sudo::/etc/hosts is below; any help would be greatly appreciated!

;; GNU Emacs: 25.1.1 Tramp: 2.2.13.25.1 -*- mode: outline; -*-
00:03:58.670758 tramp-maybe-open-connection (3) # Opening connection for root@rguha-mbp.hbs.edu using sudo...
00:03:58.690581 tramp-maybe-open-connection (6) # /bin/sh -i
00:03:58.694982 tramp-wait-for-regexp (6) #
#$
00:03:58.719429 tramp-maybe-open-connection (3) # Sending command ‘exec env SHELL=/bin/sh sudo -u root -s -H -p P""a""s""s""w""o""r""d"":’
00:03:58.719589 tramp-send-command (6) # exec env SHELL=/bin/sh sudo -u root -s -H -p P""a""s""s""w""o""r""d"":
00:03:58.720503 tramp-process-actions (3) # Waiting for prompts from remote shell...
00:03:58.751461 tramp-process-one-action (5) # Looking for regexp "\(.*\(user\|login\)\( .*\)?: *\)\'" from remote shell
00:03:58.751579 tramp-process-one-action (5) # Looking for regexp "\(^.*\(\(?:adgangskode\|contrase\(?:\(?:ny\|ñ\)a\)\|geslo\|h\(?:\(?:asł\|esl\)o\)\|iphasiwedi\|jelszó\|l\(?:ozinka\|ösenord\)\|m\(?:ot de passe\|ật khẩu\)\|pa\(?:rola\|s\(?:ahitza\|s\(?: phrase\|code\|ord\|phrase\|wor[dt]\)\|vorto\)\)\|s\(?:alasana\|enha\|laptažodis\)\|wachtwoord\|лозинка\|пароль\|ססמה\|كلمة السر\|गुप्तशब्द\|शब्दकूट\|গুপ্তশব্দ\|পাসওয়ার্ড\|ਪਾਸਵਰਡ\|પાસવર્ડ\|ପ୍ରବେଶ ସଙ୍କେତ\|கடவுச்சொல்\|సంకేతపదము\|ಗುಪ್ತಪದ\|അടയാളവാക്ക്\|රහස්පදය\|ពាក្យសម្ងាត់\|パスワード\|密[码碼]\|암호\)\).*:? *\)\'" from remote shell
00:03:58.751693 tramp-process-one-action (5) # Call ‘tramp-action-password’
00:03:58.752167 tramp-action-password (3) # Sending Password
00:03:58.753291 tramp-send-command (6) # test -e /DESCRIPTION 2>/dev/null; echo tramp_exit_status $?
00:04:01.674447 tramp-file-name-handler (1) # Interrupt received in operation (file-exists-p /sudo:root@rguha-mbp.hbs.edu:/DESCRIPTION)

Sorry, try again.
Password:
00:04:01.675658 tramp-process-actions (3) # Waiting for prompts from remote shell...failed
00:04:01.676257 tramp-maybe-open-connection (3) # Opening connection for root@rguha-mbp.hbs.edu using sudo...failed
00:04:01.704867 tramp-process-sentinel (5) # Sentinel called: ‘#<process *tramp/sudo root@rguha-mbp.hbs.edu*>’ ‘killed: 9
’
00:04:01.712764 tramp-file-name-handler (1) # Interrupt received in operation (file-exists-p /sudo:root@rguha-mbp.hbs.edu:/etc/hosts)


texts: How to time org-mode code block execution?

texts:
Is there an easy way to time how long it takes to execute source code blocks in org-mode (maybe with header arguments or similar), if so, how? Or do I have to implement it in the code itself?
I'm using python3 btw.


texts: How to check if there exists a frame in which a given buffer is visible

texts:
this question is related to the question
How to know my buffer's visible/focused status?.

I would like to check if there exists a frame in which a given buffer is visible.
I tried the following but it gives true even if scratch is invisible.

(get-buffer-window (find-buffer-visiting "*scratch*") 'visible)


texts: How to increase C stack size for R in ESS?

texts:
I can not figure out how to change the C stack size for R in ESS. I can change it in terminal as follows:

X:~$ ulimit -s
8192
X:~$ R --slave -e 'Cstack_info()["size"]'
   size
7969177
X:~$ ulimit -s 16384
X:~$ R --slave -e 'Cstack_info()["size"]'
    size
15938355

As suggested by an answer to this question on stackoverflow.

After restarting an R session in emacs (M-x R) I get the following:

> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
> options(width=113, length=99999)
> Cstack_info()["size"]
   size
8284000
>

I'm using GNU Emacs 24.5.1 and ESS version 20150622.413. I'm wondering how to make the ESS interactive R shell pick up the new C stack size?

I have not found a way to set the C stack size within R and that is why I'm posting this question.


texts: How to copy multiple specified files in eshell

texts:
The following works in a separate program terminal window (to copy multiple specified files in the same directory), but the command does not work in Eshell (No such file or directory).  Is there an alternative way of accomplishing this task using Eshell?

cp /Users/HOME/.0.data/.0.emacs/.0.sources/emacs/\
{buffer.c,\
buffer.h,\
dispextern.h,\
keyboard.c,\
nsterm.m,\
w32term.c,\
window.h,\
xdisp.c,\
xterm.c} \
/Users/HOME/Desktop/emacs/src/

Background:  What did I try?  I blocked and copied the above text and pasted/yanked it at the command prompt in an *eshell* buffer, and then I pressed the enter/return key.  What happened?  I received an error message:  No such file or directory.


texts: AUCTeX error "Symbol’s function definition is void: texmathp"

texts:
From time to time I am having trouble using auctex properly. That means, after typing-in C-c C-f C-e I receive the following error message:

Symbol’s function definition is void: texmathp

Sometimes I am also unable to type in a minus symbol -, same error message.

I have installed auctex-12.1.1 via elpa (on a Windows machine, for more information see below).

I used to have something like

(require 'tex-site)
(require 'tex-mik)

in my init.el (see below).

The strange thing is, everything works without (require 'tex-mik) but then I am unable to use C-c C-f C-e (includes an \emph{}) or C-c C-e, which I really depend on.

Any ideas what is going on?

My emacs version

In GNU Emacs 25.3.1 (x86_64-w64-mingw32)
 of 2017-09-12 built on KAEL
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Configured using:
 'configure --prefix=/tmp/emacs --without-imagemagick --without-dbus
 --with-modules 'CFLAGS=-O2 -g0''

My init.el (hopefully a MWE)

(require 'package)

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "http://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")
             ("org" . "http://orgmode.org/elpa/")
             ("elpy" . "https://jorgenschaefer.github.io/packages/")
             ))

(setq package-check-signature nil)

(add-to-list 'load-path "~/.emacs.d/site-lisp/")

(let ((default-directory "~/.emacs.d/site-lisp/"))
  (normal-top-level-add-subdirs-to-load-path))

(package-initialize)

(require 'tex-site)
(require 'tex-mik)


texts: Error when opening IPython notebook list using EIN

texts:
I am not entirely sure where to post this question (here, stackoverflow....), but I am sure some emacs experts will be able to help me here. This question is also posted here https://github.com/tkf/emacs-ipython-notebook/issues/158 , so the reader can go there for some more details.

Recently I managed to set IPython in emacs and I have been so far happily coding using the "interplay" of the two.

I now need to share some code and the IPython Notebook seems like the best tool to do so. Therefore, I have been using IPython the "normal" way until I recently learned that IPython can also be set up on emacs https://github.com/tkf/emacs-ipython-notebook .

I decided to give it a go and install all the requirements: websocket, request etc.

However, now, every time I try to run Emacs IPython Notebook via M-x ein:notebooklist-open I find the following error messages:

Contacting host: 127.0.0.1:8961
ein: [error] QUERY-AJAX--PARSE-DATA: error from parser ein:json-read
error in process filter: eq: JSON readtable error
error in process filter: JSON readtable error
ein: [error] QUERY-AJAX--PARSE-DATA: error from parser ein:json-read
Error running timerein:query-ajax-timeout-callback': (json-readtable-error)

The relevant section of my .emacs file looks like this (I am sure that most of it is not needed, but I have gone through a lot of iterations):

;;Ipython Notebook
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/request-0.2.0/")
(require 'request)
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/helm-1.6.7/")
(require 'helm)
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/company-0.8.9/")
(autoload 'company-mode "company" nil t)
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/popup-0.5.2/")
(require 'popup)
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/websocket-1.3/")
(require 'websocket)
(add-to-list 'load-path "/Users/javier/.emacs.d/elpa/ein-0.2.0/")
(require 'ein)
(require 'cc-mode)
;;(setq ein:use-auto-complete t)
;; Or, to enable "superpack" (a little bit hacky improvements):
(setq ein:use-auto-complete-superpack t)
(setq ein:use-smartrep t)

more details about my System Info can be found here https://github.com/tkf/emacs-ipython-notebook/issues/158

To my understanding the problem seems to be related to request and the fact that despite the (require 'request) the request.el seems to either not having been loaded or not being visible to ein.

At this stage I do not know what to edit/install to make it work so I can use the notebook in emacs like is shown here https://github.com/tkf/emacs-ipython-notebook/wiki/Screenshots .

I also found this Emacs EIN vs IPython shell but seems not to solve my problem.


texts: Clock in automatically when org file is opened

texts:
Is it possible to create a hook so that
It clocks in automatically whenever org file is opened for editing
Kindly help


texts:
I'd like to enable changing the font size by holding down the right mouse button and using the scroll-wheel. Emacs does however treat mouse buttons as keys, so this obviously cannot be achieved directly by a straight-forward (define-key ... (kbd ...) ...) binding.

Since I also don't want to disable the standard actions performed by "click and release" of the right mouse button, I can't just bind something to <up/down-mouse-3>. Instead, I'd like to bind a command to the scroll events <mouse-4> and <mouse-5>, that detects, whether the right mouse button is being held.

Is this possible?

Related questions point to the variable track-mouse, but it doesn't seem, like that method can distinguish different mouse buttons.


texts: How do I silently write to a temporary file?

texts:
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.


texts: magit-diff jumps to insertion/deletion in already opened window (no overlay)

texts:
I have 2 windows open: One is the magit-diff of the current repo, the other is just source codes from that repo. In source codes (the right window), I have a file opened, say "sample.txt". In magit-diff (the left window), I can see all of the deletion and insertion that occur for "sample.txt". In other words, it looks like this:

    | magit-diff                    | "sample.txt  |
    | modified sample.txt           |              |
    | + text I added                |              |
    | - text I removed              |              |

Now, if I press enter on the line "+ text I removed", then I would be taken straight to "sample.txt" at the exact line where the insertion/deletion happens.  The only problem is that this would open another buffer that overlays the current magit-diff buffer.  The original window for "sample.txt" does not change. In other words:

    | "sample.txt"                                    | "sample.txt" |
    | cursor at line of inseration/deletion           |              |
    |                                                 |              |
    |                                                 |              |

I do not want this to happen.  What I want is once I press enter in magit-diff, I would like the other window (the right window with "sample.txt" already opened) to jump to the line of insertion/deletion. If "sample.txt" is not already opened yet, then just open the file in another window. In other words, after pressing enter:

    | magit-diff                    | "sample.txt"                                     |
    | modified sample.txt           |  cursor at line of insertion/deletion            |
    | + text I added                |                                                  |
    | - text I removed              |                                                  |

Is there a way to do this within emacs? Please let me know and thank you for your help.


texts: How to enable circular scroll in emacs helm

texts: How do I wrap around and start from the beginning when I have reached the end of items in a helm buffer?


texts: I installed http://packages.ubuntu.com/zesty/emacs which includes Gnus, but there's no /usr/share/info/gnus.info.gz – am I forced to use the web wowser to read the fine manual, or is there some simple way to get the info file?


texts:
I recently used a package that overwrote C-x C-s to something other than save, causing me to lose a lot of work.  Is there a way I can advise emacs to check for a blacklist of keybindings that it shouldn't allow to be remapped?
Edit:
The package in question is (the otherwise excellent) atomic-chrome,  and this looks to be the offending line:
(defvar atomic-chrome-edit-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-x C-s") 'atomic-chrome-send-buffer-text)
    (define-key map (kbd "C-c C-c") 'atomic-chrome-close-current-buffer)
    map)
  "Keymap for minor mode `atomic-chrome-edit-mode'.")


texts:
Is it possible to set a breakpoint on an arbitrary line while already established in browser()? As a use-case: if I debug(myfunc) and while in Browse[2]> ... I realize that I need to jump forward to a point in the source file. My two current methods for dealing with this are:

Exit the function, set the breakpoint where I want it, and re-enter the browser for the function.
Continue line-by-line through the function, where my only way to speed things up a little is to use finish execution of the current loop (or function). (This can be arduous with functions that are hundreds of lines.)

What I'd love to be able to do is:

Navigate to the line I want, tag it for debugging (C-c C-t C-b, I think), then continue (M-S-c) in the debugger, where it will then continue unabated until it encounters my just-set breakpoint.

R-3.2.5-64, emacs-24.5.1 (i686-w64-mingw32), ess-16.04 (elpa: 20160602.203)

Edit: browser() is a debugger intended for in-environment inspection at breakpoints (either intentional or reactive) of uncompiled R code. This is specific to ESS, and more so to ess-tracebug within it. (Heck, perhaps the answer is solely R, in which case I can migrate to SO.)


texts: What is a string fence or comment fence?

texts:
The docstring for modify-syntax-entry says the following:

(modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE)
...
The first character of NEWENTRY should be one of the following:
...
  /           character-quote.      @   inherit from parent table.
  |           generic string fence. !   generic comment fence.

What is a fence, and when would I use one? I can't find anything in the info manual.


texts:
How can I pin a version of "smartparens". I thought If I add this to dotspacemacs-additional-packages:

(smartparens :location
   (recipe :fetcher github
           :repo "Fuco1/smartparens"
           :commit "f7db43d874ac82e4cdce234cb4e578d37207250a"))

it would work, but it doesn't. I've tried it with :version-regexp. I tried listing smartparens in dotspacemacs-excluded-packages, but it still downloads latest available on MELPA.


texts: I want to get onto the #Emacs channel on Freenode. How do I do it?


texts:
I'm trying to use xonsh as my python interpreter in Emacs (the one invoked by run-python). I tried to do this by setting python-shell-interpreter to "xonsh". This works, but there are two issues:

The prompt is printed twice (but results are only printed once)
When I try to do something like find-file in a python buffer while the interpreter is open, this hangs (until I press C-g) and gives me thef ollowing in *Messages*:

error in process filter: python-shell-comint-end-of-output-p: Wrong type argument: arrayp, nil
error in process filter: Wrong type argument: arrayp, nil


texts: Set emacs to NOT ask for password for encrypted file upon saving

texts:
If I open an (symmetric, only a password is required) encrypted org mode file, by entering the password when the file opens, upon saving the file, emacs prompts me for the password.
I would much rather have emacs NOT ask me for the password upon saving the file, and remember the password that was entered when the file was opened, for the file password when the file is saved.
Is this possible?
Thanks ahead of time......


texts: Connect to Melpa on Port 80 in Setup Script

texts:
I'm trying to setup emacs in a docker image that I am creating. I would like to create the image with a particular melpa package installed.
This is my Dockerfile:
FROM ubuntu

RUN apt-get update
RUN apt-get install -y emacs
COPY setup.el /root/.emacs.d/
WORKDIR /root/.emacs.d/
RUN emacs --script setup.el

This is my setup.el file:
(require 'package)

(package-initialize)

(setq package-archives '(("melpa" . "http://melpa.org/packages/")))

(package-refresh-contents)

(package-install 'racket-mode))

When I go to build the docker image, I get the following error:
Loading /etc/emacs/site-start.d/00debian.el (source)...
Contacting host: melpa.org:80
error in process filter: Could not create connection to melpa.org:443

I looked at the 00debian.el file to see if it had any effect on the docker build.
$ cat /etc/emacs/site-start.d/00debian.el

;; Set the default mail server and news server as specified by Debian
;; policy.

(setq gnus-nntpserver-file "/etc/news/server")

(setq mail-host-address (let ((name (expand-file-name "/etc/mailname")))
                          (if (not (file-readable-p name))
                              nil
                            (with-temp-buffer
                              (insert-file-contents-literally name)
                              (while (search-forward "\n" nil t)
                                (replace-match "" nil t))
                              (buffer-string)))))

It doesn't seem to have any effect on the package system nor does it seem to be reaching out to Melpa or Elpa.
I made the package-archives point to http Melpa as opposed to https Melpa so that I wouldn't connect on port 443. However, my system still seems to be connecting to Melpa on port 443. I did this because when emacs tries to connect over port 443 it throws an unknown certificate authority error (the certificate authority is R3).
Does anyone have an idea how I might be able to fix the certificate authority error in my docker image or otherwise get Melpa to connect over port 80?


texts: Editing a file with emacs over ssh on remote machine

texts:
I am editing configuration files with emacs on remote hosts using ssh connection. It works perfectly. But I recently made RSA keys and now I can connect to these hosts with the keys without password, but emacs cannot. It is waiting for a long time with message "waiting for prompts from remote shell" and after that says that timeout reached.
I do not understand what is wrong, please clarify :)
Thanks, guys!

Thanks for your answers. Will investigate it.
ZhengHu, I do not think that the deal is about shell settings, because Emacs can connect with these settings when I do not use RSA ssh key...


texts: Is it possible to execute a function or command at a specific time? As an  explicit example, is it possible to kill emacs at a specific time (time determined by the OS).


texts: How to include an image in the cover front before OR after the title in exported ODT from org?

texts:
I have an org document which I export to several different formats:

Markdown
PDF
HTML
ODT

I need to include an image (the logo of the company) in the cover front page, before OR after the title of the document in all the exported formats, especially in the ODT since the readers could be people with MS Word.
My directory tree is something like this:
├── Document.org
├── Document.odt
├── Document.md
├── Document.pdf
├── Document.html
├── images
│   ├── logo.png
│   ├── image1.png
│   ├── image2.png

The current command I include (which is not working) is:
#+title: @@odt:<draw:image xlink:href="./images/logo.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>@@ [Projec Name] A title here

Te title is shown, but not the image.
I need the solution for ODT exported files, not only PDF or md.
Extra question: Is there a way to include a small header image to all pages, or a water mark image in all pages?


texts: How can I prevent empty files from showing up on the Ibuffer list?

texts:
On my IBuffer I always see a *.py  file that is actually empty.
Is it possible to prevent this file to be hidden in the Ibuffer or basically remove it.
[ Default ]
    *.py                       0 Python           ~/*.py

On my configuration, I have folliwng line (find-file "*.py" t), which actually help to speed up the opening time of any Python file on my end (honestly not sure why).
I wasn't able to exclude it as well:
(setq recentf-exclude '("__init__.py\\"
            "__init__.py"
            "\\*.py\\'"
            ))

More general question should be as: how can I prevent empty files show up on the Ibuffer list that will cover *.py as well since its empty.


texts: Does your project use Elisp for build automation?

texts:
I'm building a new appliance, linking BusyBox with Tor on top of a minimal GNU/Linux operating system.  I'd like to try something different for the automated build infrastructure with this one and Emacs Lisp has been calling me lately.

Do you have a project written in C that uses automated build scripts written in Elisp?  Guile might might be a runner-up but I need to get up-to-speed quickly on the infrastructure needed, so I'm hoping for Elisp for familiarity's sake.


texts: Insert org mode links via helm-mini or refile (or equivalently using e.g. company mode)

texts:
I often want to insert a link to another file (that would be easily accessible via helm-mini or refile). I have to do this long dance of going into the target file (and potentially headline), storing a link, going back to the original file, and inserting the link).
Is there a better way to do this? Either with helm, or company mode, or even via simple hack which chains these actions together. (The ideal would be just start with some target characters like [[ and simply have autocomplete, but a helm operation is good too!)
The closest thing I've found is this, but it does other things which I'm not interested in: Insert Org-id Link at Point via Outline Path Completion


texts:
My problem is very similar to this one from Unix & Linux Exchange.

I use systemd to start emacs --daemon as my user account. Recently I have had the following problem when trying to open a new frame of my emacs process.

$ emacsclient -c
Waiting for Emacs...
*ERROR*: Display :0 can't be opened

In the question linked above, the user had old emacs daemons still running, but I only have one.

$ ps ux | grep  [e]macs
anthony    675  0.0  1.2 432560 103680 ?       Ssl  20:41   0:03 /usr/bin/emacs --daemon

I imagine my problem is related to $XAUTHORITY as suggested in the second answer of the question linked above, but I have been unable to solve the issue on my own and was hoping someone here could help. Possibly relevant information to follow:

$ echo $XAUTHORITY
/var/run/gdm/auth-for-anthony-ATsjnA/database

$ ls -l /var/run/gdm/auth-for-anthony-ATsjnA/database
-rw------- 1 anthony anthony 106 Feb 18 20:41 /var/run/gdm/auth-for-anthony-ATsjnA/database

$ ps -C emacs wwe
 PID TTY      STAT   TIME COMMAND
 675 ?        Ssl    0:02 /usr/bin/emacs --daemon DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0 HOME=/home/anthony LANG=en_US.UTF-8 LOGNAME=anthony MAIL=/var/spool/mail/anthony
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin SHELL=/bin/bash USER=anthony
XDG_RUNTIME_DIR=/run/user/1000 MANAGERPID=667

I log in with gdm into gnome-shell, and the emacs process is started with systemctl --user start emacs.service. Here's the contents of the emacs.service:

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Restart=always

[Install]
WantedBy=default.target

Any help would be greatly appreciated.

Edit

At politza's suggestion:

$ DISPLAY=:0.0 emacsclient -c
Waiting for Emacs...
*ERROR*: Display :0.0 can't be opened

I connect to the server fine in gnome-terminal with emacsclient -nw as well.

Second Edit

At Stefan's suggestion, I edited my ~/.xsessions to the following

gdmauth=$XAUTHORITY
unset XAUTHORITY
export XAUTHORITY
xauth merge "$gdmauth"

/bin/bash --login -i ~/.xinitrc

but I still have the same issue. I'm not sure if it matters, but it seems the value of XAUTHORITY changes with every log-in. I don't know when that value is assigned so that the script above will work.

Manually running xauth merge /var/run/gdm/auth-for-anthony-<random>/database finishes silently, but I still run emacsclient.


texts: org-mode internal link works only in some cases

texts:
I have an .org document with the following structure.

* Headline 1
This is some text

* Headline 2
:Custom_id: h2

This is heading number two

** Sub heading 1
<<target>>

** Sub heading 2

* Headline 3
In conclusion, this is an example

1. [[Headline 1]]
2. [[#h2]]
3. [[target]]

Only [[h2]] with the custom id works for me. The others just bring me to the top of the document. When I change [[target]] to some other string such as [[孔子]] though, it will work.

What went wrong?


texts:
I'm a newbie to eshell and I want to find the list function(s) which "find ./" calls. For the ls command I can use

which ls

which conveniently tells me where eshell/ls is, and links to the underlying function. On the other hand

which find

returns

find is an alias for `cl-find` in `cl.el`

but as far as I can see, there is no cl-find in cl.el, and clicking the link only takes me to the top of the cl.el file. How can I find the code which is evaluated by the find command? Is there any kind of convenient, general way of seeing the functions which get called by an eshell command?


texts: Fonts appear in different color in buffer

texts: When I write a big text exceeding the window bounds when starting Emacs the fonts appear in other color than the rest. If it makes any good to mention, when I disable font-lock mode text appears in one color as it is.


texts: disable company-mode when editing C++ over tramp

texts:
When editing Python files over tramp, elpy continues to use my local python distribution for completion, which is fine by be for what I need.

However, when editing C++, it uses clang output from the remote host and the round-trip is constantly hanging my editor.  Right now I just manually disable company-mode, but I am wondering how I can include a hook that says, when editing C++ over tramp, turn off company-mode.  Any ideas?


texts: In the Emacs Multi-Media System, shuffling by song is as easy as M-xemms-shuffle, but i cant figure out how to shuffle by album, or to add a random album to the playlist. Is this possible?


texts:
I would like to use column-mode to create a project rollup similar to MSProject, but much simpler and faster. I would like to have a column for :hours:, and a column for :materials_cost:. Here's the core of my question: can I create a column for :total cost: which would be this math (I'm pretending I'd write it like this):

:total_cost: = :hours: * 210 + :materials_cost:.

this is sufficiently simple to do in excel or a org-table, but doesn't use the greatness of folding in outlines which column-mode allows, with the simplicity of sums {+}. I've searched everywhere for some mention about math with properties.


texts: How to set the color for whitespace in isearch failures

texts:
I have my isearch failure face set like so:

(custom-set-faces
 ...
 '(isearch-fail ((t (:background "#660c00"))))
 ...
)

It works for the most part, highlighting text which doesn't match in that color. However, whenever I write failing whitespace, i.e. a space or a tab which has no match in the buffer, the face that is used to highlight it is a brighter shade of red which is not the same color as the rest of the unmatched text. Furthermore, this color of whitespace is replaced by my custom isearch failure color when non-whitespace characters are written after it.

Here is an example demonstrating this.

I suspect that I can solve this issue by setting some face somewhere, but I'm not sure which face is the culprit here and I've looked and looked for it to no avail.

FYI, I'm using GNU Emacs 25.1.50.2 on OS X 10.11.6.


texts:
If I have Emacs split horizontally and on top I'm editing elisp code and on the bottom I am in the shell. By default, Emacs makes the two windows equal in size, but I'd like the shell buffer smaller. I was wondering how I could do that.

Original question asked by Steve on SO: How to Change size of split screen emacs windows?


texts: Is it possible in org-mode to export a * heading to a \begin{heading} \end{heading} block construct?

texts:
I'm trying to export a heading as a block construct.
Something like

* heading
  Content
* Another Heading

gets exported to

\begin{heading}
Content
\end{heading}
\section{Another Heading}

Using something like a tag :block: or a :export: block property for the heading.

I am now using this answer for is-it-possible-to-export-content-of-subtrees-without-their-headings for some of my document which touches on a similar modification which leads me to believe it should be possible.


texts: How do I stop evaluating an expression in Lisp Interaction mode?

texts:
So I made a loop that prints out numbers from 0 - 100,000,000 and it's still going.

How do I force stop it?

I have a feeling that something like this is going to happen again one day..


texts: org-mode TODO items not recognized first time

texts:
My org-mode TODO keywords are set as follows:

(setq org-todo-keywords
      '((sequence "NITPICKING(!)" "NITS_SENT(!)" "NITS_DONE(!)" "PROOFS_SENT(!)"
          "PROOFS_RECEIVED(!)" "ACS_RECEIVED(!)" "ACS_ASSIGNED(!)"
          "ACS_DONE(!)" "|" "READY(!)")))

I have a headline that starts in the NITPICKING state. Here is what happens:

I press C-c C-t to call org-todo. State changes from NITPICKING to NITS_SENT, as it should, but syntax highlighting gets lost for that headline.
I press C-c C-t again, it puts me back in the NITPICKING state, with correct highlighting.
I press C-c C-t again, it puts me in the NITS_SENT state, now with correct highlighting.
Further calls to org-todo work correctly.

So it's just the first transition that's getting screwed up. Here is what the timestamps look like:

  - State "NITS_SENT"  from "NITPICKING" [2016-05-23 Mon 13:27]
  - State "NITPICKING" from ""           [2016-05-23 Mon 13:26]
  - State "NITS_SENT"  from "NITPICKING" [2016-05-23 Mon 13:25]

It works properly if I use buffer-local keywords instead of defining org-todo-keywords in my init file. But this is the global setup that I need, and I'd prefer to do it the way I've done it.

Is there something wrong with my code? Why would only get messed up for a single state?

Edit (in response to @nispio):

This behavior occurs even when I start emacs with emacs -q and then manually evaluate the setq command above.

After some further experimentation, it also seems that the same behavior occurs regardless of the starting state. So, for instance, if I open a .org file with a headline in the ACS_RECEIVED state and execute org-todo, it puts me in the next (ACS_ASSIGNED) state, but without syntax highlighting; the next execution of org-todo puts me in the initial (NITPICKING) state, with proper syntax highlighting, and it works correctly from there.

Further edit: the problem is that the headlines were empty apart from the TODO state. I wanted the headline to be empty to make my agenda view cleaner, since the name of the org file together with the TODO state is all the info I need at a glance. But it seems that having an empty headline means that the TODO state is interpreted as the title, which is why the first call to org-todo sets me in the initial state.

So, I would like to refine my question to the following: is there any way to have headlines that are empty apart from the TODO state?


texts: Undo custom command without moving the point

texts:
I would like to have a command that inserts some text at a distance, while keeping the point in place during its own execution and while being undone.

To illustrate the point, consider following example:

(save-excursion (goto-char (point-at-eol)) (insert "test"))

As I was writing this, I found a solution through making an invisible change at the original position, at the beginning and at the end of execution.
This will ensure that original position is the last position visited by point during undo or redo.

Following solution works, however I would like to apply more conventional approach if one exists:

(atomic-change-group (insert " ") (delete-char -1)
                     (save-excursion (goto-char (point-at-eol))
                                     (insert "test"))
                     (insert " ") (delete-char -1))


texts:
I have the following customizations in my .spacemacs file

(defun dotspacemacs/layers ()
   dotspacemacs-additional-packages '(smart-tabs-mode))

(defun dotspacemacs/user-config ()

  (setq-default font-latex-fontify-script nil)

  (add-hook 'LaTeX-mode-hook
            (lambda ()
              (setq indent-tabs-mode t
                    indent-line-function 'indent-relative)
              (smart-tabs-mode-enable)
              (smart-tabs-advice indent-relative tab-width)
              (electric-indent-mode -1)
              )))
  )

I use indent-relative since Latex-mode does not use tabs at all apparently (see How can I configure AUCTeX to use tab characters for leading indentation?).

If, in LaTeX-mode, I indent a line with an indentation that starts with a tab and is followed by spaces, and then hit Enter + Tab, smart-tabs-mode takes care that the next line will be indented exactly the same way, i.e. the combination of tabs and spaces ist preserved.

However, if I use newline-and-indent to get a newline (or leave electric-indent-mode on), the indentation is spaces only. Is that a limitation of smart-tabs-mode or am I missing something?


texts: orgmode beamer: set image width for source block output?

texts:
This is one of my slides:

** Test image width

*** First sub                                          :B_block:BMCOL:
:PROPERTIES:
:BEAMER_env: block
:BEAMER_col: 0.5
:END:
#+header: :exports results
#+BEGIN_SRC ditaa :file images/hello-world-round.png :cmdline -r
+--------------+
|              |
| Hello World! |
|              |
+--------------+
#+END_SRC

#+ATTR_LATEX: width=0.4\textwidth
#+RESULTS:
[[file:images/hello-world-round.png]]
*** Second sub                                          :B_block:BMCOL:

The #+ATTR_LATEX: width=0.4\textwidth does not work. I still get image with width=\textwidth.

How do I set width for the image exported by the SRC block?


texts: How to set up hotkey for compiling c code and run the compiled file?

texts:
I used to use tmux with vim to write codes in C/C++. So I split the screen into two in tmux and then press F3 to "make" the file. And then I can press F4 to run the "main" file in the next subscreen.

Now I have switched to emacs and am wondering if there is anyway to do the same.


texts:
I am trying following a book (Mastering Emacs) and right now stuck on a section about working with Helm. I tried to install through various means, listed there, and found online, my last attempt was with "straight.el" package manager. My current init.el file has only 1 line related to the helm, which is
(straight-use-package 'helm)

After restarting and seeing that there were no issues on launch, I tried to call basic helm command, helm-M-x and i got an error.

Symbol’s value as variable is void: while-no-input-ignore-events

Which I also had when trying to install the helm through regular "package-install". I went for helm wiki and found the trick after installing about opening the terminal, going to the helm folder inside .emacs.d, and trying to launch the terminal command 'emacs-helm.sh'. I tried so and got back

emacs-helm.sh: command not found

in both Emacs and outside Ubuntu terminals. I tried also to sudo snap install helm --classic, but installing helm through it didn't help, the command was still not "found". From my understanding, if "emacs-helm.sh" doesn't work that's the starting point that should be attempted to be fixed. Can someone recommend how to deal with this issue and what should be my logic when I am trying to debug such problems with packages?


texts: Wanderlust: save/restore queued operations accross sessions

texts: I have scoured the source code of Wanderlust and Elmo, but have not found a mechanism to save/restore queued operations across Emacs sessions -- e.g., delete certain items from the Inbox, move certain items to Spam, etc.  I'd like to do work offline and kill Emacs and then open Emacs at a later date and process the queued operations.  How can this be achieved?


texts:
I seem to have a problem with mu4e not correctly autofilling email addresses. According to this page, this should happen automatically. And for many (most?) addresses it does. But then others it doesn't get for whatever reason.

Any ideas where to start here?


texts: Standard emacs lisp function for "collect-if"

texts:
Is there a standard emacs-lisp function replacement for

(defun collect-if (PREDICATE LIST)
  (loop for el in LIST if (funcall PREDICATE el) collect el))

Example toy application: Extract the odd numbers from a list of numbers

(collect-if (lambda (x) (/= 0 (% x 2))) '(1 2 3 4 5))
(1 3 5)


texts:
I'd like to run emacs in powershell (on windows 7) with emacs -nw with the misterioso theme.

When I M-x load-theme misterioso the theme'ing doesn't happen.  However when I M-x load-theme manoj-dark, I get pretty colors.

Is there something I can do to fix powershell to play nicely (or fiddle with misterioso)?


texts: Attach to running remote shell with eshell/TRAMP/dtach

texts:
I often use GNU Screen to keep remote sessions alive.  Since I live in Emacs, I'd really like to be able to resume a running remote shell session from within Emacs.

GNU Screen implements all sorts of fancy things like terminal multiplexing and character drawing that I really don't need.  I'm really only interested in having detachable and resumable shell sessions, so something as simple as dtach might be sufficient.

I'm using this function to open an SSH session and reconnect to a running dtach session in shell-mode (taken from here):

(defun ssh-dtach (host)
  "Open SSH connection to remote host and attach to dtach session."
  (interactive)
  (let ((explicit-shell-file-name "dtach")
        (explicit-dtach-args '("-A" "/tmp/emacs.dtach" "-z"
                               "/bin/bash" "--noediting" "-login"))
        (default-directory (format  "/ssh:%s:" host)))
    (shell (format "*ssh %s*" host))))

Despite minor quirks, this works almost fine for shell-mode, but in Eshell this just starts a subprocess, so the terminal becomes very limited (e.g. no path autocompletion).

How can I configure Eshell to connect to a running dtach session upon connecting to a remote server?

EDIT:
As I thought about this problem again, I realised that it isn't entirely clear what I actually want.  Here's a list:

I want to stay in eshell, not in some subprocess
upon reattaching I want the output of the remote session to be replayed and the remote command history to be available
I want to be able to interact with a running remote process (e.g. a running yum install waiting for my input)

It seems that I'll need to write a bit of elisp code to make this all work with dtach.


texts: disable on-click mail sending in java mode

texts:
using spacemacs in java mode, moving the mouse over an email address displays in the modeline the text mouse-1, C-c RET: mail this address. And if I click on it, a blank email sending form is opened in emacs (strangely enough that doesn't happen in haskell mode or fundamental).

My issue is that while I don't use the mouse much when using emacs, I often use it to focus the emacs window. And if there's somehow an email address exactly where I click, I open that email compose buffer, which is never what I want, because (at this point) I don't use emacs for email sending.

How can I disable that "click to compose an email" feature?


texts:
I saved point to register, closed buffer / restarted Emacs and got:

user-error: That register’s buffer no longer exists

I want Emacs to open file if necessary and go to point.


texts: Evaluate parts inside text-property string using read syntax?

texts:
I just discovered that it is possible to define strings with text properties using the special read syntax. Now I'm trying to evaluate a value of a property within the string definition so something like this:

#("Example" 0 1
  (:some-prop
   "something"
   :some-other-prop
   (concat "how to eval concat "
           "here?")))

would become:

#("Example" 0 1
  (:some-prop
   "something"
   :some-other-prop
   "how to eval concat here?")))

I could not figure it out. I know I could use put-text-property but maybe
there is some backquoting technique or something else I could use instead?


texts:
I have a timer which call a function itself calling start-process. Whenever the current buffer's directory changed (deleted/moved), I have the error
start-process: Setting current directory: No such file or directory

The command ran by start-process is not directory specific, it can be run anywhere. So my workaround is setting default-directory to a directory which probably exists:
(let ((default-directory user-emacs-directory))
  (start-process ...))

Question. Is that a common workaround to prevent start-process fail ?


texts: Remove strange keybindings from YASnippet

texts:
I have YASnippet installed in emacs 24.5, which wasn't working and after a lot of different attempts at a fix, I now have the basics working, however - somewhere along the way - I have collected the following key bindings:

This isn't a question of altering the TABbehaviour (I've seen a lot of threads on that).

When I have yas-minor-mode enabled, I cannot type the letter 'c' at all.
Here is what is stored in my YASnippet minor mode keybindings:

Key bindings:
key             binding
---             -------

C-c         Prefix Command
TAB         yas-expand
c           Prefix Command     <---- *
<tab>       yas-expand

c -         Prefix Command     <---- *

C-c &       Prefix Command
C-c k       yas-expand

c - c       Prefix Command     <---- *

C-c & C-n   yas-new-snippet
C-c & C-s   yas-insert-snippet
C-c & C-v   yas-visit-snippet-file

Now I am no expert, but those I have marked look a little too funky.

How can I remove them?

I have tried recreating those bindings and setting them to nil - no joy.

If there is no fix, would deleting the package and reinstalling it solve the issue? I am not sure where those kaybindings are actually stored... ?


texts:
I am using Emacs 25.3 on Mac and when I try to open some linux kernel code, the behavior is different as below:

I cannot simply open a C file, but I am prompted for arch each time.
Occasionally, emacs tries to 'parse' all the include files (I can see in the minibuf). Plus, when I use Tramp, this takes even longer and emacs is as good as hanged.

Looks like it is the linux development environment that is causing this, but when I try to disable through 'M-x global-ede-mode', EDE is actually getting enabled (I see that it writes an ede-projects.el file).

I simply want to open and edit files, and will use other tools for build and config. Any help is appreciated.

The messages after choosing the file are -

'Select Linux' build directory', and
'Select target architecture'.


texts: PS1 under term and shell doesn't match system

texts:
I find under both shells and terms in Emacs my prompt does not appear as I would expect based on my $PS1 appears as...

# Shell under Emacs
]0;slackline@583.datascience.work.com: /home/slackline@samba.sheffield.work.comslackline@583 ~ $ echo PS1
\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]

# Terminal under Emacs
0;slackline@583.datascience.work.com: /home/slackline@samba.sheffield.work.comslackline@583 ~ $ echo PS1
\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]

# GNOME or xfce4 Terminal
slackline@583 ~/ $ echo PS1
\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]

I set $PS1 in ~/.bashrc so that its sourced each time a shell is started (rather than login)...

$ grep PS1 ~/.bashrc
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '

I found this thread which suggests its a down to differences between login and non-login shells and whether PS1 is being sourced from /etc/profile or a user-config, and suggests that under Emacs since its non-login its user configs that are used first.  Checking /etc/profile to rule it out it has the following...

$ grep PS1 /etc/profile
if [ "$PS1" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
      PS1='# '
      PS1='$ '

...what is strange to me (if I've understood it correctly) is that \h:\w is commented out in this file and based on the above linked thread shouldn't be being sourced, yet it appears that this is what is being pre-pended to the prompt I would expect to see.

EDIT : This looks like a partial solution although I've given it a whirl and doesn't appear to have worked, will try again though.

EDIT2 : Found a solution to this problem and its down to how PROMPT_COMMAND is set...

if [ -z "$INSIDE_EMACS" ];
    then
    export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'                       |
else
    export PROMPT_COMMAND=''
fi


texts:
Is it possible to refile a dated item into the appropriate place in a datetree?

I have seen some posts that describe the use of org-archive-location but I cannot get that to work - perhaps its the wrong thing to use?


texts: Properly formatting Outlook links in org-html-export

texts:
I've followed a solution found at superuser for capturing the unique identifier (UID) of an Outlook message stored in a PST file, and creating a org link of the form:

[[outlook:UID][Message subject]]

Selecting this link in emacs opens the message in Outlook using a little Lisp stored as org-outlook.el in my .emacs.d/lisp directory, so I can access specific messages right from org. Really nice solution for integrating emails that I need to reference right from my notes.

The problem is that I also like to export my notes as html using org-html-export through C-c C-e h o, but the Outlook links get rendered as:

Message subject

which tries (and fails, of course) to open a local file named "UID" instead of:

Message subject

which my browser correctly passes off to Outlook.

Is there a way for me to custom define the link export format for an outlook: link? Kinda a newbie here, and I couldn't find anything on the topic.

Thanks


texts: Helm Occur - jump to next (or previous) occurence

texts:
my emacs settings

➜  settings git:(develop) ag 'occur'
helm-settings.el
38:(global-set-key (kbd "C-s")  'helm-occur)

How to jump between different search results while you're in edit screen (i.e. not to invoke the helm-occur screen each time). Before the helm-occur mapping - it was simply a continuation of C-s clicks.

Any ideas?