texts:
I have run into an error with latest version of org-mode and cannot seem to find how to track it down. I have reported the issue on the org mail list, but so far the only response indicates they could not reproduce the issue.

So far I have tried the following

Ensured it is not a mixed version issue. A common org problem occurs when you try to install a new version, but some of the old version has already been loaded. I used all the standard techniques to avoid this problem and even deleted the version of org which comes with emacs 25. So I'm pretty sure it is not a mixed version problem.
I have tried with both emacs 25.1 and emacs 25.2-rc2. Same issue
I have tried using different accounts (same desktop) - one of which was a completely fresh account.
I've check for load-file shadows, but all looks correct.
I get the same issue with both the org and org-plus-contgrib packages
I also tried the org package in elpa (which is same version as the one in the org archive).
I have downloaded and built the package from sources.
I have tried opening an org file without source blocks, which is fine, but then when I open the first one with a source block, I get the error.
I have tried org-reload with and without the arg to load from *.el before opening the org file with source blocks and it makes no difference.

The error only occurs when I am also loading the goto-address-prog-mode mode (part of goto-addr package in emacs).

When you first visit an org file with a src_block, you get the error org-mode fontificaiton error at line x. It doesn't seem to matter what the src-block type is i.e. emacs-lisp or sh both give the same error. The code in the sr block is not fontified.

If you then kill the buffer and then re-open the org file a second time, it loads fine - no errors and src blocks are fontified.

This makes me suspect that org is loading something, but is not loading it until after it has loaded the org file - possibly goto-address-prog-mode is holding things up. However, I cannot work out how to generate a stacktrace. Setting debug-on-error has no effect.

I have been using the goto-address-prog-mode with org for some time and only noticed this problem when updating most recent version from org repo.

Ideas? Suggestions? How can I dig into this to find out what the problem is? How can I get a debug backtrace? Can anyone else reproduce this issue?

The minimal init.el file I use to reproduce this problem is below. I ensure there is nothing in my .emacs.d/elpa directory (in fact, I delete it before starting).

(require 'package)

(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(package-initialize)

(unless (package-installed-p 'org-plus-contrib)
  (package-refresh-contents)
  (package-install 'org-plus-contrib))

(require 'org)

(require 'goto-addr)

(add-hook 'prog-mode-hook 'goto-address-prog-mode)

and the test org file I use is

* Test
  This is a test of fontification in org files which contain source blocks

  First, we test an sh block

  #+BEGIN_SRC sh
    echo "Hello world"
  #+END_SRC

  Next, a simple emacs lisp source block

  #+BEGIN_SRC emacs-lisp
    ;; A simple test
    (message "A Test")
  #+END_SRC

and I start emacs with

emacs -Q -l .emacs.d/init.el --debug-init


texts: How can I get `emacs --daemon` to load the Spacemacs configuration?

texts:
I have configured my ~/.emacs so: It either launches default emacs via the default init.el, or runs the Spacemacs init.el

I run Spacemacs via a spacemacs shell script, ~/bin/spacemacs

#!/bin/sh
export USE_SPACEMACS="1";
emacs $1

and this is the content of ~/.emacs

(setq use-spacemacs (getenv "USE_SPACEMACS"))
(when (> (length use-spacemacs) 0)
    (setq user-emacs-directory "~/.spacemacs.d/"))   ; defaults to ~/.emacs.d/
(load (expand-file-name "init.el" user-emacs-directory))

How can I run emacs --daemon with the configuration from the ~/spacemacs.d/init.el? I may have to adjusted to disable stuff like the server-start and other such options.

For the meantime I have settled on starting Spacemacs in background screen terminal and running the emacsclient commands in my regular terminals.


texts: How can I have emacs save my desktop periodically, so it will persist even if I do not exit with C-c C-x in desktop-save-mode or save manually?


texts: Elisp - Changing directory in shell buffer

texts:
I want to open an instance of a terminal emulator (in my case term) and go to a specific directory, all with a single Elisp function. My idea was to send a specific string programmatically to the shell, telling it to change to a specific directory. But I don't know how I should do it, and I've not been able to find an alternative (like sending the cd command as the shell is opened).
How can I achieve this?


texts: Org mode fontification error in # in python and ipython source blocks

texts:
I am having problems with the fontification of python and ipython source blocks when the code contains curly brackets "{}". For instance, the following snippet
#+BEGIN_SRC python :results drawer
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
a=1
print("a={}".format{a})
#+END_SRC

does not fontify correctly in either python or ipython source blocks.
As a consequence, when exporting the org file to HTML (C-c C-e h h), it fails with the following message:
font-lock-fontify-keywords-region: Invalid function: #<subr progn>

If changing the code snippet to:
#+BEGIN_SRC python :results drawer
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
a=1
print("a=%s" % a)
#+END_SRC

the block fontifies and the file is exported the HTML correctly.
Has somebody experienced similar problems?
Many thanks in advance!


texts: Org mode indents scheduling by default even though I don't indent my text. Can I configure it so that org-schedule doesn't indent?


texts: X11 GUI low quality display when using server

texts:
Why is Emacs X11's display such bad quality, and how do I fix it?

When I use Emacs Cocoa locally, I get a good visuals.  But when I use the X11 forwarding on my department's server, the quality is horrendous.  How do I fix the X11 version?

I'm doing this all on Mac OSX (El Capitan).  Here are some screenshots of the difference between the local, cocoa version and the X11 version:

Emacs Cocoa locally:

Emacs X11 server version:


texts: Getting the key binding for the current command

texts: this-command-keys and this-command-keys-vector return the entire key sequence that fired the current command.  However, such sequence will contain any prefix argument, too.  Is there a function or variable - let's call it this-command-key-binding - to get just the key sequence for the command, without any prefix, so that (key-binding (this-command-binding)) returns the same value as this-command, even in the presence of a prefix argument?


texts: org-mode error: Region to sort contains a level above the first entry

texts: When calling org-sort-entries on an outline item I get the error "Region to sort contains a level above the first entry", with no indication of what or where the problem is. What does this error mean, and how do you fix it?


texts: How to transform abbrevated dates in org table

texts:
The input column represents the year without 201 and month and day without leading zeros. I must transform these into full date strings.

After a couple of hours to take step 1, I'm wondering if there is a more elegant way to achieve the steps left:

Year: Find first first digit from left: Append 201 before (done)
Month: Find 5th digit from 1 to 9: Append a 0 before
Day: Find last digit from right which is between 1 to 9: Append a 0 after
Insert hyphen after year, month and date

|-------+----------+------------|
| input |   output |   expected |
|-------+----------+------------|
|  9725 |  2019725 | 2019-07-25 |
|   811 |   201811 | 2018-01-01 |
| 71212 | 20171212 | 2017-12-12 |
|-------+----------+------------|
#+TBLFM: $2='(baz @0$1)

(defun baz (cell)
  (concat "201" cell))

Explanation: The input represents the batch processing of approx. thousand grocery receipts. The goal was to hit as few key strokes as possible.


texts: Fold second-level (all methods) when opening a py-file (with hs-minor-mode)

texts:
I use hs-minor-mode currently.
When point is on class Foo... a M-x hs-hide-level will fold all methods of that class.
This is exactly the state I need for all *.py files when I open them. Is it possible?
When I open a python file all methods of all classes (there could be more then one!) should be folded.
hs-hide-level was pointed out in that answer.
https://emacs.stackexchange.com/a/50144/12999


texts: Ignore a repeated diary entry, just this once, in Org Agenda?

texts:
In a nutshell: I'm looking for a way to selectively hide one instance of a repeated diary entry so it doesn't show up in my org-agenda.

I have many repeating diary entries for things like weekly meetings, etc. using basic sexp syntax.

I've set up my org-agenda to include these diary entries in my weekly/daily views.

Sometimes, a weekly event is cancelled. How can I hide/delete it from my org agenda just this once, without deleting the entire entry in the diary?


texts:
Specially when editing my init.org file, I usually want to push every single change to origin. So I want to write a function to do this, I am almost there but still need some help.

(defun cesco/automatic-push ()
    (magit-stage-modified)
    (magit-commit (concat "-m \"" COMMIT MESSAGE "\""  ))
    (magit-push MAGIT-CURRENT-BRANCH)
)

I want the commit message to be the current day/time and push the current branch to origin.

Update

I can successfully commit, but magit-push is running too fast so there is nothing commited yet. How can I make it wait for the commit to be done before attempting to push?

(defun cesco/push ()
    (interactive)
    (magit-stage-modified)
    (magit-commit (concat "-m \"" (format-time-string "%Y-%m-%dT%H:%M:%S")  "\""))
    (magit-push)
  )

Update 2

Code

(defun cesco/automatic-push ()
  (interactive)
  (magit-run-git "commit" "--all"
         (format-time-string "--message=%F %R"))
  (let ((current-branch (magit-get-current-branch)))
    (message "PUSHING!!!!")
    (magit-git-push current-branch
                    (concat "origin/" current-branch)
                    (list "--dry-run")
           )
    ))

1 try

  0 git … commit --all --message\=2017-05-08\ 01\:10
[master 03f269c8b701] 2017-05-08 01:10
 1 file changed, 3 insertions(+), 2 deletions(-)

  0 git … push -v --dry-run origin master\:refs/heads/master
Pushing to git@github.com:cescoferraro/dotfiles.git
To git@github.com:cescoferraro/dotfiles.git
   798f05653e9e..03f269c8b701  master -> master

Removing (list "--dry-run")

  0 git … commit --all --message\=2017-05-08\ 01\:11


texts: Org-mode C-u C-c C-c fail to add checkboxes to the rest of the list

texts:
the original content like this:

* TODO My list
  - list
    - sub-list A
    - sub-list B
    - sub-list C

after I have typed C-u C-c C-c at the position "- list", the content like this:

* TODO My list
  - [ ] list
    - sub-list A
    - sub-list B
    - sub-list C

it does not work as my expected:

* TODO My list
  - [ ] list
    - [ ] sub-list A
    - [ ] sub-list B
    - [ ] sub-list C

the documention is state that " C-u C-c C-c  on the first item of a list with no checkbox will add checkboxes to the rest of the list."

Is there anything wrong or my misunderstanding?


texts: Multiple timestamps for various states in TODO lists

texts:
I'm finding TODO lists in org-mode incredibly useful. For example, say I have a task to send an email, I define the following sequence in my init.el file:
;; Sequence in TODO list
(setq org-todo-keywords
      '((sequence "EMAIL" "SENT" "|" "RESPONSE" "CANCELLED")))

Once the email is sent, I switch it from EMAIL to SENT and then to RESPONSE when I get an email back. Great! And I can timestamp the RESPONSE like so:
;; Timestamp on completed tasks
(setq org-log-done 'time)

Now, I'd like to extend this further, so that I get a timestamp for SENT, which I can do by shifting "|" to the left of SENT. But when I toggle to RESPONSE, I don't get a new timestamp because the task is already closed.
Is there a way to get timestamps that persist for multiple states of a TODO list item (i.e., for both SENT and then RESPONSE)?


texts: How to change CSS files to indent to 2 spaces?

texts:
I have only installed emacs straight out of the box. I have not installed anything else:
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

my .emacs file:

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(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-enabled-themes (quote (wombat))))
(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.
 )

(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))

(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq js-indent-level 2)


texts: How to strip invalid UTF-8 characters from a string?

texts:
TL;DR:

I have a string with characters that are unencodable in UTF-8, and I
need to remove these characters before writing the string to a file.

For instance, the following snippet creates a file that contains an
invalid UTF-8 byte sequence. I would like this sequence to just not be
present in the output file.

(let ((coding-system-for-write 'utf-8))
  (write-region "This is invalid: \x19008e" nil "~/outputfile"))

By checking this character with describe-char, I can see Emacs knows it is not encodable through UTF-8. So there must be a way to detect these characters and remove them.

The Background

I have an emacs-lisp script which converts docstrings to html files,
which must be entirely in UTF-8. The following snippet shows
essentially what I've been doing so far.

(with-temp-file output-file
  (insert symbol-name "\n" symbol-documentation)
  (set-buffer-file-coding-system 'no-conversion))

Where symbol-documentation is the string returned by
describe-variable (the content of the Help buffer).

This seemed to work fine at first, but now I've realised this was
causing some files to contain byte-sequences that are not valid UTF-8.
Some perpetrators are tibetan-precomposition-rule-alist,
language-info-alist, composition-function-table. By manually
checking their documentation, I can see my Emacs indeed fails to
comprehend part of the content.

Q: How can I ensure only valid UTF-8 byte sequences are written to the output file?
I'm perfectly fine with skipping these invalid sequences entirely
(instead of trying to understand them). I just want to make sure the
output file is valid.

I tried changing no-conversion to utf-8, but then my script gets
interrupted by a Select coding system: prompt, and the problem
still happens.


texts:
I define a function ess-rmarkdown to compile RMarkdown documents with polymode.

(use-package polymode
  :ensure t
  :config
  (use-package poly-R)
  (use-package poly-markdown)
  ;;; MARKDOWN
  (add-to-list 'auto-mode-alist '("\\.md\\'" . poly-markdown-mode))
  ;;; R modes
  (add-to-list 'auto-mode-alist '("\\.Snw\\'" . poly-noweb+r-mode))
  (add-to-list 'auto-mode-alist '("\\.Rnw\\'" . poly-noweb+r-mode))
  (add-to-list 'auto-mode-alist '("\\.Rmd\\'" . poly-markdown+r-mode))
  (markdown-toggle-math t)
  ;; from https://gist.github.com/benmarwick/ee0f400b14af87a57e4a
  ;; compile rmarkdown to HTML or PDF with M-n s
  ;; use YAML in Rmd doc to specify the usual options
  ;; which can be seen at http://rmarkdown.rstudio.com/
  ;; thanks http://roughtheory.com/posts/ess-rmarkdown.html
  (defun ess-rmarkdown ()
    "Compile R markdown (.Rmd). Should work for any output type."
    (interactive)
                                        ; Check if attached R-session
    (condition-case nil
        (ess-get-process)
      (error
       (ess-switch-process)))
    (let* ((rmd-buf (current-buffer)))
      (save-excursion
        (let* ((sprocess (ess-get-process ess-current-process-name))
               (sbuffer (process-buffer sprocess))
               (buf-coding (symbol-name buffer-file-coding-system))
               (R-cmd
                (format "library(rmarkdown); rmarkdown::render(\"%s\")"
                        buffer-file-name)))
          (message "Running rmarkdown on %s" buffer-file-name)
          (ess-execute R-cmd 'buffer nil nil)
          (switch-to-buffer rmd-buf)
          (ess-show-buffer (buffer-name sbuffer) nil)))))
  )

To bind ess-rmarkdown function to F5 key I use:

(with-eval-after-load 'polymode
  (define-key polymode-mode-map (kbd "<f5>") 'ess-rmarkdown))

Unfortunately, after reloading my init.el file, the following warning appears:

Symbol's value as variable is void: polymode-mode-map

I kindly as for any advice.

EDIT: Entering emacs with --debug-init returns me:

Debugger entered--Lisp error: (void-variable polymode-mode-map)
  (define-key polymode-mode-map (kbd "<f5>") (quote ess-rmarkdown))
  (lambda nil (define-key polymode-mode-map (kbd "<f5>") (quote ess-rmarkdown)))()
  eval-after-load(polymode (lambda nil (define-key polymode-mode-map (kbd "<f5>") (quote ess-rmarkdown))))
  eval-buffer(#<buffer  *load*> nil "/home/andrej/.emacs.d/init.el" nil t)  ; Reading at buffer position 4255
  load-with-code-conversion("/home/andrej/.emacs.d/init.el" "/home/andrej/.emacs.d/init.el" t t)
  load("/home/andrej/.emacs.d/init" t t)
  #[0 "\205\266


texts: Automatically set property value from agenda view

texts:
I'm trying to create a function that will set a tag and a property with current timestamp to an header entry selected in agenda.

This is what I came up with so far, it adds the tag but it does not add the property at all:

(defun my-org-agenda-set-focus-for-task ()
  "Add :focus: tag and a PROPERTY with current timestamp to the item selected"
  (interactive)
  (when (eq major-mode 'org-agenda-mode)
    (org-agenda-set-tags "focus" "ON")
    (org-set-property "FOCUS" (format-time-string "%Y-%m-%d %H:%M"))))

I also tried to use org-agenda-set-property but it crashes saying that I'm passing to many arguments. How can I make it work?


texts: Region does not get deselected on move commands using `push-mark` from Elisp

texts:
By using shift-select-mode, I can select some region via holding down Shift + arrow keys. When I then stop pushing Shift and press other keys the region get deselected. But this is not the case when using push-mark function from Elisp code - the region stays selected when I move the cursor.

Here's an example of my function to select current symbol under cursor:

(defun sandric/select-symbol-under-cursor ()
  "Select symbol under cursor."
  (interactive)
  (when (not (region-active-p))
    (let (bounds pos1 pos2 mything)
      (setq bounds (bounds-of-thing-at-point 'symbol))
      (setq beginning (car bounds))
      (setq ending (cdr bounds))
      (goto-char beginning)
      (push-mark beginning t t)
      (goto-char ending))))

It works as expected (leaving aside little redundance with setq and not using let bounds for now), and if I place cursor on a symbol and call the function it selects the symbol at point as the region.

The problem occurs when I press the right arrow key afterwards. The region is not deselected - instead it expands.

How can I make cursor movements after using my command not expand/decrease the region unless the Shift key is pressed, like the usual shift-select-mode behavior.


texts: how to assign a list or string to current-prefix-arg?

texts:
current-prefix-arg's
help doc says, the variable can contain a list (or) number (or) minus symbol. I mostly set a number as the prefix-arg by keypress, C-[1-9].

But how can i assign a list or string to current-prefix-arg?
   I ask this, since isearch-forward

(defun isearch-forward (&optional regexp-p no-recursive-edit)
  (interactive "P/np")
  (........))

takes the search string through interactive key "P"  but i am having zero clue on how to set a string to this prefix-arg?


texts:
Whenever I hit enter to get to the next line when writing a function for example emacs indents an addition tabs worth of space.  I'll try to sketch out the problem:

fun pow(x : int, y : int) =
----if y = 0  *hits RET*
--------then 1  *hits RET*
------------else x * pow(x,y-1)

In this scenario the dashes represent the indentation that is happening and I'm using enter to go to the new line.  I'm totally new to emacs so I'm not sure if the issue has to do with a bug or user error?  Could someone who is more experienced using emacs please point me the right direction, this behavior is driving me nuts!

Just to clarify a few things, I'm having this same issue on both my PC and Mac. When I say "hits RET" what I really mean is that I'm hitting the ENTER key.  I'm assuming that I'm in SML mode because on the bottom line (I forget the technical name for it) it says (SML). I've also changed from FUNDAMENTAL mode to SML-Mode by typing M-x sml-mode. I'm using Emacs v26.1 and SML-Mode v6.9.

I wanted to also mention that I turned off electric-indent-mode and now here is the new behavior. I'll type if ..., hit RET, type then, hit RET, it goes to the right place. If on the other hand I just type if, hit RET, hit TAB, type then - the indentation goes haywire like it was previously. I'm wondering if I'm not hitting the right buttons in the right order or some other really silly beginner's mistake?


texts: Why does my dynamic module using zeromq return empty strings when running interactively?

texts:
I am trying to write a dynamic module for zeromq. It works when I test it in batch mode, but not interactively. The layout of the test is that I run a server (https://github.com/jkitchin/emacs-modules/blob/master/zeromq/hwserver.c) that just returns the string "World" for every request. This works.

The module defines a function https://github.com/jkitchin/emacs-modules/blob/master/zeromq/mod-zmq.c that is registered in Emacs as zmq-send-and-recv which takes one string argument, sends it to the server, and gets a request. I can see that the argument is sent to the server correctly, and when I test it in a batch mode (eg make test in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/makefile), it appears to get the response back correctly too.

But If I try to run this interactively from emacs, e.g the first source block in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/zeromq.org, or running the code in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/test.el the msg is sent to the server but I get empty strings back in Emacs.

I can't figure out any reason for this and wondered if anyone has any ideas on debugging it.


texts:
I would like to define a custom org-mode link, which accepts the following syntax:
[[yt:<video ID>]]
and produces an image link equivalent to this:
[[https://youtu.be/<video ID>][http://img.youtube.com/vi/<video ID>/0.jpg]]

Any ideas?


texts:
Is there a package to log Emacs activity?

I've been logging my productive activity with various tools, including shell and browser history.  More I use Emacs, it's hard to track what I do. Because more and more staff is done in Emacs without touching any other tools.

I'm aware of command-log-mode.  The latest version has time-stamps and save capability but it does not log what file I am working on.  Maybe it is a good candidate for a starting point.

I'm also aware that you can time with org-mode.  I'm using it but I always forget to switch to new work when I interrupted by my colleagues.

BTW, I'm not interested in real life logging with Emacs.  I'm not looking for any extra gadget nor ways to wear Emacs.  It sounds interesting but not for now.


texts: Create a sub-mode of an existing mode which overrides certain functions?

texts:
I want to make a few customizations to cmake-model.el. The big-picture view of this lisp file is as follows:

...

;; This function I want to modify
(defun cmake-indent ()
  ...
  )

...

;; Mode definition.
;;
;;;###autoload
(define-derived-mode cmake-mode cmake--parent-mode "CMake"
  "Major mode for editing CMake source files."
  ...
  )

What I want to do is to create a minor mode ros-mode which would override the cmake-indent() function with my own, but keep everything else the same compared to the original cmake-mode.el. The mode line should show ROS when the minor mode is active.

I have no experience with creating minor modes, but I feel like this should be easy for someone with experience. Thank you for helping!


texts: How to make persistent buffer list above frame like in vim powerline

texts: I want to implement behavior similar to mine vim config, where all basic info was below the main frame, like modes, position in file, changes, but above the frame is list of all buffers, with separated by color active buffer for active window. Is it possible to do somehow? thx. Can you suggest some plugins or scripts implementing similar behavior?


texts:
For some of my JavaScript projects I use Flycheck with the javascript-eslint checker to highlight problems. This works great. I disabled many of js2-mode's checks so that they don't overlap with Flycheck's javascript-eslint checker.
Some of my other JavaScript projects do not have an ESLint config, so flycheck-verify-setup says "No checker to run in this buffer." For these files Flycheck does not show any problems even when there are some. I would like to enable js2-mode's checks for these files.
In js2-mode-hook how can I determine whether Flycheck is using a checker to check the buffer so that I can conditionally enable or disable js2-mode's checks?


texts: Colors for different priorities in Org mode

texts:
I have configured Org mode with a face attribute for priorities with these lines in my init.el:

(set-face-attribute 'org-priority nil
                    :foreground "aquamarine1"
                    :background "black"
                    :inherit font-lock-keyword-face
                    :inverse-video t
                    :box '(:line-width 2
                           :color "orange"
                           :style released-button))

But I'm wondering if there is a way to set different colors for priorities #A, #B & #C.


texts:
I have setup prelude and the setup is just great. There is one thing that bothers me: whenever I type double x, emacs opens helm-mode-execute-extended-command.

Is there a way to disable this shortcut?


texts: Same face within headline after new line in org mode

texts:
A new line within a headline currently results in a different (the default, I guess) face. (Different from the beginning of the headline, I mean.) How can I make the entire headline face the same?
MWE
* I'd like this,
to be the same face as this.
* Thanks!

Screenshot of what that looks like on my machine:

Also (and better!) I'd like to know how I could figure this out myself. E.g. where in the manual would I look. (I couldn't find anything in the org mode manual.)


texts: Why doesn't (use-package dired) work for me?

texts:
(use-package dired) complains:

Debugger entered--Lisp error: (error "Package ‘dired-’ is unavailable")

But I see others' emacs configurations do use (use-package dired), for example:

https://github.com/lunaryorn/.emacs.d/blob/088ac57/init.el#L829

https://github.com/bbatsov/emacs.d/blob/d94a751b/init.el#L295

https://github.com/mattss/emacs.d/blob/4e3cb1f5/init.el#L113

What's needed to make dired use-package-able?  Is this something to do with cask?


texts: Execute marks without confirmation in mu4e

texts:
In mu4e (email in Emacs with mu), the default behavior of x is to prompt for confirmation before executing marks, such as "delete" or "archive." I want to execute marks without confirmation.

Inspecting the function bound to x, I see:

(mu4e-mark-execute-all &optional NO-CONFIRMATION)
...
If NO-CONFIRMATION is non-nil, don’t ask user for confirmation.

So I run M-:, (mu4e-mark-execute-all t) and it works.

But defining the key in the mode map

(define-key mu4e-main-mode-map (kbd "x") (lambda() (interactive) (mu4e-mark-execute-all t)))

does not rebind the key.

How can I redefine the x key, or make no confirmation the default?


texts: Erc, rcirc, and circe, just won't connect

texts:
So this is quite strange and I'm not sure how solvable this will be. But yesterday erc was working just fine, and then today it is stuck on trying to connect to the server (irc.freenode.net) with the error of:

Connection failed!  Re-establishing connection...
*** ERC terminated: failed with code 22

I can't find any way to figure out what "code 22" means. I'm on a Mac 10.11.6 (El Capitan), installed emacs through brew, and ran emacs like so: emacs --no-init-file. I've also uninstalled/reinstalled by deleting both the ~/Library/Caches/Homebrew/emac* and /usr/local/Cellar/emacs.

Lastly during a fresh reinstall of running emacs --no-init-file I also tried to run both M-x erc, M-x irc (in emacs), and M-x erc-tls all fail to connect. I have also tried different ports 6667-7000 any help is appreciated, and thank you.


texts: Issue with python mode in 24.5 on Mac OSX Yosemite: python-rx missing?

texts:
I installed Emacs 24.5 using homebrew

$ brew install emacs

and the Emacs-Live package collection.  Most things work really well, but I'd like to get a python IDE going in emacs (so I don't have to leave emacs to run python, etc.)

First, I open up one of my python programs, foo.py:

print 42

and verify this works from the shell:

M-xshell

$ python foo.py
42

Great.  The underpinnings seem to be working.

Following the minor-mode help (M-x helpm), which shows many key bindings, I now start the python subprocess:

C-cC-p

 Python 2.7.10 (default, Jun 10 2015, 19:42:47)
 [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>>

Now I try to send my program to this subprocess:

C-cC-c

Wrong type argument: stringp, nil

Uh-oh.  Ok, I can deal with this.  Back to *Help* mode. M-xhelp, find the entry for C-cC-c

C-c C-c      python-shell-send-buffer <<<--- that's a hyperlink

clink on the hyperlink:

python-shell-send-buffer is an interactive compiled Lisp function in
`python.el'.  <<<--- that's a hyperlink

click on that hyperlink:

(defun python-shell-send-buffer (&optional send-main)
  "Send the entire buffer to inferior Python process.
When optional argument SEND-MAIN is non-nil, allow execution of
...etc...

put the point cursor in the defun and press C-uC-M-x, which instruments the function for Edebug. Another C-cC-c in my python buffer and Edebug stops in this function.  Info-mode has full documentation of Edebug,

M-xinfoRet
mm ElispRet
mm DebuggingRet
mm EdebugRet

and I do lots of stepping into and checking stuff, which I won't repeat here.  Suffice to say, I eventually find the offending line inside python.el, line 4138

(set (make-local-variable 'outline-regexp)
       (python-rx (* space) block-start))

When I try to step into this call of python-rx, Edebug either tells me that it can't find function python-rx,

Symbol's function definition is void: python-rx

or emacs goes into the weeds and I have to Force-Kill it, depending on how much other stuff I've done in the debugger session.  I try looking for python-rx

M-x find-grep-dired

/usr/local/Cellar/emacs/24.5/share/emacs/24.5/lisp/progmodes

(I think this is where homebrew puts emacs lisp code for program modes)

python-rx

nothing found :(

I find it hard to believe that python mode is actually broken in this distro -- millions would have picked up their pitchforks and torches and taken to the streets.  It must be something I've done wrong.  I'd be grateful for any advice.


texts:
When i click or C-c C-o on pdf link in org-mode, Emacs opens the pdf with gimp.

I don't find how to overide this behavior.

Tried with these two recipes

(require 'openwith)
(openwith-mode t)
(add-to-list  'mm-inhibit-file-name-handlers 'openwith-file-handler
(setq openwith-associations '(("\\.pdf\\'" "evince" (file))))

With first recipe, no change on behavior

(org-add-link-type "pdf" 'org-pdf-open nil)

(defun org-pdf-open (link)
  (let* ((path+page (split-string link "#page="))
         (pdf-file (car path+page))
         (page (car (cdr path+page))))
    (start-process "view-pdf" nil "evince" "--page-index" page pdf-file)))

With second recipe, no change in behavior

Can you help me ?

Best regards


texts:
I can execute the function neotree-toggle with M-x.

However, none of these result in opening neotree, like described here and here

(global-set-key (kbd "C-e" ) 'neotree-toggle)
(global-set-key "C-e" 'neotree-toggle)
(global-set-key (kbd "\C-e" ) 'neotree-toggle)
(global-set-key "\C-e" 'neotree-toggle)

Where is my mistake? I don't see it.


texts:
I want to kill some buffers created by default, such as the GNU Emacs, but putting:

(kill-buffer "*GNU Emacs*")

On the .emacs doesn't work. I guess this code is called before the initial buffers are created. There should be some kind of hook, but I want it to be run only at the start up, to clean all the initial buffers I don't need.

Edit:

Tried after-init-hook and emacs-startup-hook without success.

Edit 2:

Put some code on .emacs to see what's happening:

(defun buffer-hook-function ()
  (append-to-file (format "%s" (buffer-list)) nil  "log.txt")
  (append-to-file "\n" nil  "log.txt")
  )

(append-to-file "Executou .emacs\n" nil  "log.txt")

(add-hook 'emacs-startup-hook (lambda () (append-to-file "emacs-startup-hook\n" nil  "log.txt")))
(add-hook 'after-init-hook (lambda () (append-to-file "after-init-hook\n" nil  "log.txt")))
(add-hook 'before-init-hook (lambda () (append-to-file "before-init-hook\n" nil  "log.txt")))
(add-hook 'window-setup-hook (lambda () (append-to-file "window-setup-hook\n" nil  "log.txt")))
(add-hook 'emacs-startup-hook (lambda () (append-to-file "window-setup-hook\n" nil  "log.txt")))
(add-hook 'buffer-list-update-hook 'buffer-hook-function)

After starting emacs, the output on log.txt is:

Ran .emacs
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1*)
after-init-hook
window-setup-hook
emacs-startup-hook
window-setup-hook
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1*  *temp*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*  *temp*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*  *temp*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*)
(*scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1* *GNU Emacs*)
(*GNU Emacs* *scratch*  *Minibuf-0* *Messages*  *code-conversion-work*  *Echo Area 0*  *Echo Area 1*)

I'm not finding a hook for being executed after all those initial buffers are created... Maybe I'll need to do some shenanigan to capture this event.


texts:
I'm just looking to add files to my org-agenda-variable. I added a single file successfully but am unable to use multiple.

With the code below in my .emacs.el file, the agenda buffer shows 0 TODO's despite there being plenty in the files specified.

Am I using list wrong?

Per another question I checked and the code is not in the customize block.

(setq org-agenda-files (list "C:/Users/Hugh/Documents/CS/Org/todo_dissertation.org"
    "C:/Users/Hugh/Documents/CS/Org/todo_LT_misc.org"
    "C:/Users/Hugh/Documents/CS/Org/todo_ST_misc.org"
    "C:/Users/Hugh/Documents/CS/Org/todo_career.org"))

C-h v user-init-file gives:

Its value is "c:/Users/Hugh/AppData/Roaming/.emacs.el"

which is the file I'm editing.

M-x emacs-version returns:

GNU Emacs 26.1 (build 1, x86-64-w64-mingw32) of 2018-05-30

M-x org-version returns:

Org mode version 9.1.9 (release-9.1.9-65-g5e4542 @ c:/Users/Hugh/emacs/share/emacs/26.1/lisp/org/


texts:
Is there any hook that runs every time a keyboard binding is created/added?

Here's my problem:

I use dvorak and also another layout(some exotic utf8 script) both at system level. And I've got used to dvorak layout(without input-change) for my keyboard bindings. But when I change to the utf8 layout(at system), I've to change back to dvorak every single time I want to do something using shortcuts.

One method I thought was to add new bindings by mapping existing ascii keys to these utf8 chars(on dvorak layout) everytime a keyboard binding is made. Using a list of all bindings doesn't look like a good idea, mostly because it's too much work.


texts: spacemacs key bindings in plain vanilla evil emacs

texts:
As the title suggests, I would like to use spacemacs like keybindings in plain vanilla evil emacs.

The spacemacs key bindings are very intuitive. But the package is too heavy for my low-end laptop. Even simple operations take a long time. So, I am trying to see if there is an intermediate solution.


texts:
Copy/Paste seems broken for hexl-mode, eg. M-w copies the hex tables to the clipboard, rather useless. Since hexl-mode has overwrite-mode by default, how can the following be implemented?

M-w should copy marked binary data to the clipboard
C-y should insert contents of clipboard by overwriting, starting at cursor position
C-w should overwrite the marked area with hexl-mode-clear-value
DEL should set current byte to hexl-mode-clear-value and go to previous byte

hexl-mode-clear-value should be a customisable variable defaulting to \x00.

If Emacs is not in overwrite mode, copy/paste should work like plain text files, though this seems like low priority / undesirable since skewing binary data equals data corruption in most cases.


texts: ModuleNotFound for absolute imports in Emac's Python Repl

texts:
For some reason, emacs does not seem capable of evaluating absolute imports for any python project I run. Here is my project layout:

├── loxy
│   ├── errors.py
│   ├── __init__.py
│   ├── loxy.py
│   ├── scanner.py
│   ├── token_.py
│   └── token_type.py
└── setup.py

When I enter an inferior python shell, I am incapable of importing any of my project's modules that are declared using absolute or relative imports. E.g.

from X.Y import y
from .Y import y

Marking the above and running python-shell-send-region, or just sending the whole buffer, results in a ModuleNotFoundError for any import that does either of the above.

The only format that is unaffected is:

from Y import y

But this is incompatible with packaging with pip, which I will often do to test the package as a whole as a program via local installs, pip install -e . from the root of the package. Pip will work just fine with either relative or absolute imports, but emacs' inferior repl works with neither currently. This puts me at an impasse.

Any ideas?

Extra details:

Auto completion works just fine with my setup. Virtualenvs are detected fine with pyenv-mode and imports work with any of the styles I listed above. This is probably a path related error, but I am not sure how/why it is happening.

Update

Answered my own question after wasting a lot of hours trying to fix my workflow. Not proud of it but hope it might help someone else better understand how python works from within emacs.


texts:
I am trying to use Webkit, but I can't get emacs to find the necessary python library EPC that I installed via pip (in Anaconda). Here is the error message:

Debugger entered--Lisp error: (file-error "Cannot open load file" "No such file or directory" "epc")
  require(epc)
  eval-buffer(#<buffer  *load*> nil "/Users/evar/.emacs.d/myPackages/webkit.el" nil t)  ; Reading at buffer position 2348
  load-with-code-conversion("/Users/evar/.emacs.d/myPackages/webkit.el" "/Users/evar/.emacs.d/myPackages/webkit.el" nil t)
  require(webkit)

I am using High Sierra.


texts: Can occur match phrases that stretch across multiple lines?

texts:
Q: (how) can I use occur to match a phrase that
stretches over multiple lines?

Consider the following buffer:

Here's a line of text with the phrase "kittens and puppies".
Here's an awkward alternative: the phrase "kittens and
puppies" stretches across two lines.
Here's a false positive: "kittens and otters".

I'd like to identify all the locations in the buffer that contain
the phrase "kittens and puppies".  If I use occur, however, the
following two problems arise:

the phrase "kittens and puppies" matches only the first line,
and not the second/third where the phrase wraps over a line
break.
the phrase "kittens" (or "kittens and") also matches the false
positive on the last line.

How, if at all, can I use occur to locate the relevant lines in
the buffer -- those that contain the entire phrase, or the
beginning of one that wraps across lines?  If occur can't do it,
is there an occur-like alternative that can?


texts: How to convert DOS/Windows newline characters to Unix format within GNU Emacs?

texts: Is there a way to tell GNU Emacs to convert DOS/Windows newline characters in a file to Unix format?


texts: How to continue giving list number after insert a block of code

texts:
GNU Emacs 24.5.1 (i686-pc-mingw32)

Org-mode version 8.2.10 (release_8.2.10 @ e:/emacs/share/emacs/24.5/lisp/org/)

In my org file,

1. one thing
   #+begin_src sh
   ls -la
   #+end_src
2. second thing

But when I export html, it shows:

  one thing

  ls -la

  1 second thing

This happens when I use Yasnippet, some lines can't be indent.
For example,

#+begin_src dot :file xx :cmdline -Tpdf :exports none :results silent
 sss
#+end_src
[[file:xx]]

The [[file:xx]] can't forcely indent.

Update-2015-12-9


texts: Are there Emacs "starter kits" with few to no third-party packages required?

texts:
I've seen quite a few starter packages for Emacs (Starter kit, Prelude, etc), but all of them I'm aware of use lots of third-party packages downloaded from the various package repositories, such as GNU, MELPA, Marmalade, ...  I'm about to start using Emacs on a closed network - really closed - as in, no connectivity to the internet whatsoever. If I'm to use any third-party packages, I'll have to have IT review the packages, which takes forever. Too many requests for review will just result in wholesale rejection of all of it.

So I'd like to know: are there any similar setups out there that use packages included in Emacs to begin with? (I'm using Emacs 24.5) I can get away with a little bit of keyboarding stuff in, and maybe three or four third-party packages, but that's about it. This has to run on Windows 7.

EDIT: I should have mentioned that I will be writing Python code on this system. I've been using flycheck on my internet-connected machine, but I'll be using flymake on the stand-alone network machine. Flymake is apparently more difficult to set up, but not that much more difficult. This kind of thing is what I was going for in the original question: everything else being equal, I'd rather use flycheck, but things aren't equal, and I'd like to know how to set up flymake. Another example: I've been using auto-complete - I love the tooltip-like presentation of possible completions - but I should probably try to stick with built-in stuff like dabbrev, pcomplete, and so on. Not trade-offs I'd like to make, but there it is.


texts:
When I set org-startup-indented to be t, I see the following error on opening any .org file and the error refused to go away i.e. it reappears instantly after pressing q.

Debugger entered--Lisp error: (void-function org-time-add)
  org-time-add(nil (0 2 0))
  org-indent-add-properties(#<marker at 1 in projects.org> 482265 (0 2 0))
  org-indent-initialize-buffer(#<buffer projects.org> (0 2 0))
  org-indent-initialize-agent()
  apply(org-indent-initialize-agent nil)
  timer-event-handler([t 0 0 200000 t org-indent-initialize-agent nil idle 0])

The org mode config which produces this error can be seen below. I observe that if remove the last line (setq org-startup-indented t), the above error is not encountered. Any idea what's wrong with my configuration? Thanks!

   (use-package org
        :ensure org-plus-contrib
        :pin org
        :requires use-package-hydra
        :config
        (require 'ob)
        (require 'ob-async)
        (require 'org-agenda)
        (require 'org-compat)
        ; (require 'org-tempo)

        (setq org-confirm-babel-evaluate nil
                  org-export-babel-evaluate 'inline-only)

        (org-babel-do-load-languages
         'org-babel-load-languages
         '((emacs-lisp . t)
           (ein . t)
           (org . t)
           (makefile . t)
           (latex . t)
           (gnuplot . t)
           (R . t)
           (python . t)
           (shell . t)))

        ;; Do not evaluate org-babel source blocks during export
        (setq org-export-babel-evaluate nil)

        (setq org-startup-indented t))

System specifications:

    - OS: macOS Catalina 10.15.1
    - GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-09-02
    - Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ ~/.emacs.d/elpa/org-plus-contrib-20191125/)


texts:
I'm still new to org-mode and am trying to set up this org-roam package. My goal is to have the buffer containing backlinks automatically show whenever I open a file, but can't seem to get that configuration set up. Here's my .init file for org-roam:

(use-package org-roam
      :hook
      (after-init . org-roam-mode)
      :custom
      (org-roam-directory "~/org/")
      :bind (:map org-roam-mode-map
              (("C-c n l" . org-rOam)
               ("C-c n f" . org-roam-find-file)
               ("C-c n b" . org-roam-switch-to-buffer)
               ("C-c n g" . org-roam-graph-show))
              :map org-mode-map
              (("C-c n i" . org-roam-insert))))

(setq org-roam-link-title-format "R:%s")
(setq org-roam-completion-system 'ivy)


texts: File at a glance feature - how to enable it?

texts:
Sublime text has this file at a glance feature, where you see the whole file in miniature.

How can I enable this in emacs? How is this feature called?


texts: Syntax Highlighting of Common Lisp User-Defined Macros in Emacs

texts:
I would like to start writing a few simple Domain Specific Languages in Common Lisp and would like the names of macros I define to be highlighted as if they were Common Lisp functions or macros in Emacs.
Below is a simple example which is not precisely the code I am hoping to write but it shows the kind of functionality I desire.
(defmacro class* (class-name superclasses slots)
  (let ((slot-declarations
     (loop for slot in slots collecting
          (list slot :accessor slot :initform nil))))
    `(defclass ,class-name ,superclasses ,slot-declarations)))

(class* graph () (nodes edges))

What I would like is for class* in the second form to show up in magenta (given the default colours in my Emacs installation) and graph should be highlighted in blue.
I have seen some examples of how to adjust syntax highlighting for LaTeX, but I could not extend those to work for me in Common Lisp.


texts: How to insert leading spaces/tabs in yasnippet?

texts:
yasnippet does not respect spaces or tabs when they occur at the start a line.

In my snippet file I have

   example

which executes as

example

Escaping with \ doesn't work.

How do I get leading spaces/tabs?


texts:
I have the following in my ~/.gnus:

(gnus-demon-add-handler, 'gnus-demon-scan-mail 5 t)
(gnus-demon-init)

I expect that gnus will be checking for new emails every 5 min, however this doesn't happen. What am I doing wrong?


texts: Using SMIE for language without comment syntax

texts:
I'm making a major mode for json (which has no comments), and using SMIE for 'free' indenting.

I've currently got a half-baked grammar called json-grammar, and no rules-function.

Consequently, I'm invoking smie-setup as

(smie-setup json-grammar (lambda (method arg) ()))

However, in a few places I'm calling smie-indent-line, and when I do, smie-indent-line eventually calls comment-normalize-vars

This function asks for a value comment syntax, and insists on having some value. Given that I want to use SMIE for indentation, how can I avoid this problem?


texts: Use `.dir-locals.el' to append to `before-save-hook' as a buffer local variable

texts:
I want to use .dir-locals.el to append to the before-save-hook in a project for c++ files.

Currently I'm using:

(add-hook 'c++-mode-hook
          (lambda ()
            (add-hook 'before-save-hook 'clang-format-buffer nil t)))

This will set before-save-hook as a buffer local variable ignoring everything that I set globally.

How can I create a buffer-local variable of 'before-save-hook' that takes the value from the global version and then adds clang-format-buffer?

Another thing that is a little bit annoying is that this will only be applied after the second file I open in the project. In the first cpp file that I open the hook is not applied.


texts: By default Emacs load the file .emacs on my system. I know if I want to start Emacs with the init file .emacs2, I should run the Emacs with the argument like emacs -q -l ~/.emacs2. Is it possible to load the init file .emacs2 in the current Emacs which is previously loaded with .emacs?


texts: Electric pair mode's delete adjacent pairs functionality not working in Slime REPL

texts:
Part of Emacs's electric-pair-mode functionality (controlled by a variable called electric-pair-delete-adjacent-pairs) is that when the point is between an empty set of delimiters and you delete the opening one, it also deletes the closing one for you: if the point is at the pipe character in (|), pressing backspace will delete both the opening and closing parenthesis.

I like this functionality very much but annoyingly it doesn't work in the Slime REPL. I do have electric-pair-mode enabled in the REPL, and it does do the other things it is supposed to, like insert the closing parenthesis automatically when you insert the opening one, or wrap the region in parenthesis when the mark is active and you press (. Just deleting adjacent pairs doesn't work. How do I get that functionality in the Slime REPL? (I think the answer has to do with keymap precedence. Maybe...)

EDIT: Here is how I'm testing this: I'm using Emacs 26.1 (on both GNU/Linux and on Windows 10, the same problem appears) and Slime 2.23. To test I run emacs -Q and then evaluate this in the scratch buffer:

(package-initialize)
(setq slime-contribs '(slime-repl slime-indentation))
(setq slime-lisp-implementations '((sbcl ("sbcl"))))
(require 'slime)

Then I run M-x slime and when the REPL appears, I run M-x electric-pair-mode. Then typing a ( inserts () leaving the point between the parenthesis. Typing backspace then deletes only the opening parenthesis insetad of both.


texts: How to transpose two arguments of a function call for C family languages?

texts:
How to swap two arguments for C function calls? eg:

my_function(foo, bar, baz);
~~~~~~~~~~~~~^ (cursor location)

Should be transposed to the right to make:

my_function(bar, foo, baz);

The simple case works for this similar question.

But fails with:

my_function(&foo, *bar, baz[2]);
~~~~~~~~~~~~~ ^ (cursor location)

Giving:

my_function(&*bar, foo, baz[2]);

From what I can tell this is because these functions rely on backward-sexp which doesn't account for some characters used in C code.

For reference, this is the code: from https://emacs.stackexchange.com/a/11062/2418

(defun custom-calculate-stops ()
  (save-excursion
    (let
      (
        (start
          (condition-case e
            (while t (backward-sexp))
            (error (point))))
        stops)
      (push start stops)
      (condition-case e
        (while t
          (forward-sexp)
          (when (looking-at "\\s-*,")
            (push (point) stops)))
        (error (push (point) stops)))
      (nreverse stops))))
(defun custom-transpose-args ()
  (interactive)
  (when (looking-at "\\s-") (backward-sexp))
  (cl-loop with p = (point)
    with previous = nil
    for stop on (custom-calculate-stops)
    for i upfrom 0
    when (<= p (car stop)) do
    (when previous
      (let*
        (
          (end (cadr stop))
          (whole (buffer-substring previous end))
          middle last)
        (delete-region previous end)
        (goto-char previous)
        (setf
          middle
          (if (> i 1) (- (car stop) previous)
            (string-match "[^, \\t]" whole (- (car stop) previous)))
          last
          (if (> i 1) (substring whole 0 middle)
            (concat
              (substring whole (- (car stop) previous) middle)
              (substring whole 0 (- (car stop) previous)))))
        (insert (substring whole middle) last)))
    (cl-return)
    end do (setf previous (car stop))))


texts:
Suppose I have a buffer and I make several indirect buffer clones of it. Is it possible to kill all these buffers except for the currently visited one?

I have found buffer-base-buffer in the manual, which allows to find the parent base buffer, but is there a way of listing all the buffers, that are indirect and have this base-buffer? (without going through all buffers and comparing their buffer-base-buffer).

More precisely, the operation I want to have is "Leave only (1) this buffer from all the indirect ones sharing the same base and (2) the base buffer itself. Then make the base look just like the current indirect buffer (narrowing, point, ...?), so that the indirect buffer can be killed as well and all I am left with is the base buffer."


texts: formatting dates in Emacs when run as a daemon

texts:
I run Emacs on a Linux (actually Xubuntu 19.04) machine and my localization settings call for an Italian locale.

When generating timestamp, however, I'd like to have English months and weekday names. A quick look to the documentation gives the answer to this: set system-time-locale to "C" and that's all.

So I did and put

(setq-default system-time-locale "C")

in my ~/.emacs.d/init.el and everything worked, until I tried to run emacs as a daemon.

If I start emacs in daemon mode (either starting it from the command line or using systemd) and then connect to the server with emacsclient, the above setting is not taken into account: if I ask the value of the variable I get "C", sure enough, but if I try

(format-time-string  "%Y-%m-%d %a %H:%M")

I get the weekday in Italian (as per the LC_TIME environment variable) If I then set system-time-locale to the value it apparently already holds by:

(setq-default system-time-locale "C")

then (format-time-string  "%Y-%m-%d %a %H:%M") prints the weekday in English as expected.

What is even more weird, at least for me, is that once I did the above call to setq-default it start using the right locale in all the client frames. either existing or created afterward.

It should be noted too that if I start the server from a running emacs instance (by M-x server-start) then everything works fine so my problem do really appears to be connected with frame creation.

I solved my problem, sort of, by adding something like this

(lambda (&optional frame)
     (setq-default system-time-locale "C"))

to after-make-frame-functions but I don't really like this solution; among other things because the above code doesn't need to be called at each frame creation: doing it once would be enough.

So, where is the question in all this? There are two, in fact:

why does the system-time-locale behave differently in server mode?
Is there a better or best-practice way to set this variable when emacs run as a daemon?


texts: Make pdf-tools remember the page I was on

texts:
How to make pdftools remember the page I was on when I close a PDF document, restart Emacs and reopen the PDF? Some PDF readers after opening a document go to the last page the user was on and don't start from the beginning, I'd like Emacs to do the same.

I tried elisp I found on Github ,none of the snippets work for me. When using the last one I get this error when trying to open a PDF that was previously opened:

  File mode specification error: (error "Buffer is not associated with
  any file :[parent directory name]")

The PDF opens fine but doesn't go to the bookmarked page, it starts from the beginning.

I also tried bookmark+. It works but I have to remember to set bookmark manually before closing the PDF which is inconvenient.


texts: Kill buffer when closing emacs with emacsclient

texts:
I am using emacs for writing email with mutt. Email are stored in /tmp even after I sent them (until /tmp is cleared). Since I start emacs with emacs--daemon, I have all the emails I have written during the session opened as buffers when launching emacsclient.

I don't like this behavior. I would like emacs to kill the opened buffer when C-c C-x is pressed (and to not have this buffer charged when open a new window of emacs with emacsclient.

How can I do this?


texts:
I know there are ways to preview markdown as you type but is there a way to avoid this duplication of text (rendered and pain text in different buffers)?

Basically, I want to type in the preview. What I'm looking for goes like this:

As I type in

# Headline

, the characters making up the word "Headline" already are being rendered so I see

  Hea

and as I type a "d", it changes to:

  Head

Or some other convenient way of rendering it live without duplication, for example in every line but the one the pointer is currently in.


texts: How to get title and author in org mode export to beamer presentation?

texts:
The org-export to beamer gives the following error when the first lines include title and author info.

#+TITLE: Presentation Title
#+AUTHOR: Name

"Wrong type argument: listp, #("Name" 0 4(:parent (#0)))"

I have used this format many times and don't know why this error is occurring now. Has there been a change in org-export engine?
I have reinstalled org-mode(Version 8.3.1) and tried other ways of specifying author and title as in following answers link1

#+BIND: org-latex-title-command "\\title{De leerplandoelstellingen}\n\\date[mei 2014]{9 mei 2014}\n\\maketitle"

and adding the following to the init file as suggested here.

(eval-after-load "ox-latex"

  ;; update the list of LaTeX classes and associated header (encoding, etc.)
  ;; and structure
  '(add-to-list 'org-latex-classes
                `("beamer"
                  ,(concat "\\documentclass[presentation]{beamer}\n"
                           "[DEFAULT-PACKAGES]"
                           "[PACKAGES]"
                           "[EXTRA]\n")
                  ("\\section{%s}" . "\\section*{%s}")
                  ("\\subsection{%s}" . "\\subsection*{%s}")
                  ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))

Any solutions? Thanks.


texts: How to gnuplot a referred evaluated table in org-babel?

texts:
Hitting ctrl-c ctrl-c on the gnuplot code block returns:
org-babel-ref-resolve: Reference ‘foo’ not found in this buffer

#+srcname: foo
#+begin_src python :results output raw :exports code
  import random
  out="| %s | %s |"
  for x in range(0, 10):
          pair=(random.randrange(1000), random.randrange(1000))
          print(out % pair)
#+end_src

#+RESULTS: foo
| 232 | 867 |
| 196 | 951 |
| 489 |  94 |
|   0 | 327 |
| 369 | 758 |
| 178 | 854 |
|  80 |  71 |
| 859 | 174 |
| 760 | 181 |
| 461 |  22 |

#+begin_src gnuplot :var data=foo :file gnuplot.png :exports results
  reset
  set terminal png size 500,375
  plot data u 1:2 notitle
#+end_src

Someone else seems to have no problem with the upper code example 1

Remark

Following @Tobias' answer below, I got rid of the reference issue. Though instead of a
plot, I have this gnuplot message below. Interestingly, the +#RESULTS foo values
don't match those in the message buffer:

Terminal type is now 'qt'
gnuplot> cd '/home/ra/'
gnuplot> data = "| 138 | 87 |
gnuplot> | 372 | 843 |
         ^
         invalid command

gnuplot> | 297 | 799 |
         ^
         invalid command
...
..
.

Footnotes

1 https://stackoverflow.com/a/9462567/1172907


texts:
Is there a World time converter under emacs and/or orgmode?
As everything moves online, it occurs more often than before that I want to schedule in orgmode an online event which occurs in some other part of the world, with a time in a distinct time zone (e.g. "9pm in Malaisia" or "9pm in GMT+8"). If the time zone is specified it is a simple mental gymnastic to compute my local time (e.g. from GMT+8 to GMT-3), which I nevertheless would like to delegate to emacs. But when the time zone is not specified, just the location (e.g. "Malaysia"), I usually go to a website, which does break the workflow of capturing an event.
I would like to be able to enter a time coordinate (i.e. date and time) using a variant of org-time-stamp which

takes as an extra parameter the location (e.g. Malaysia) or time zone (e.g. GMT+8) of the event;
computes the correct time for my own time zone (e.g. GMT-3); and
copies in the buffer both the active time stamp and an inactive time stamp with the original time and time zone specified.

For instance, programming a 1h video talk at 9pm in Malaysia on the 27th of March would result in the time stamp  <2021-03-27 Sat 10:00-11:00> ([2021-03-27 Sat 21:00-22:00] in Malaysia, GMT+8). I guess I could program (nice lisp exercise, taking care of the potential change of date when an event is close to midnight!), but I am curious to know if such a solution already exists before reinventing the wheel: maybe people scheduling plane flights already had it working in emacs, a simple internet search did not reveal anything.


texts:
I've recenly started to convert my init.el to using use-package, and have so far not found any problems with that -- except that I can't get ESS to work for all languages.

I have installed the package ess from Melpa. If I don't mention this at all in the init file, normal ".r" files get opened with ess-mode (showing as up as ESS[S]) as major mode, so there seems to be some automatic configuration going on. ".Rnw" files, on the other hand, don't get opened in ESS. Additionally, I want to use julia-mode in ESS (which is supposed to work automatically; the julia-mode package is also installed). So I added the following:

(use-package ess
  :mode (("\\.[rR]\\'" . R-mode)
         ("\\.[rR]nw\\'" . Rnw-mode)
         ("\\.jl\\'" . julia-mode)))

However, this does not help anything. When opening a ".jl" file, there is no julia function available, as there should; and there's always a warning

  File mode specification error: (error Autoloading failed to define
  function Rnw-mode)

So, how am I supposed to set that up? I see that in most documentations, ESS mode is compiled by hand and loaded by (require 'ess-site) -- does that make the difference?

I'm using Emacs 25.1.


texts: In a Python code is it possible to give a color to called functions?

texts:
As a theme I am using Dracula.
For example I have this example code piece coloring:

When cursor is on terminate() and I typed M-x customize-face it is linked to (default ‘all faces’). I am not sure which variable's color should I change.

This is example coloring in the SublimeText where functions such as: terminate, is_internet_on, error, session_start_msg has a different color rather than white. I was wondering is it possible to achive this in emacs as well?


texts:
(string-match-p "^\(./\|../\)" "../lib/tern")

returns false.

What is the correct regex pattern to check if the string begins with ./ or ../?


texts: Disable mic-paren in the minibuffer (or at least in ido)

texts:
I'm replacing a buggy code that was suppose to show a matching brace in the minibuffer in case it was off-screen with the following:

(paren-activate) ;; activates mic-paren
(setq paren-match-face 'highlight)
(setq paren-sexp-mode t)
(setq paren-highlight-offscreen t)

This works almost perfectly. The only problem, it highlights the matching braces also in the minibuffer when ido shows its thing.

How can I disable mic-paren in the minibuffer?

For reference, here is the old code snippet:

(show-paren-mode t)
(setq show-paren-style 'expression)
;; Show in the mini-buffer the matching brace in case it is off screen.
(defadvice show-paren-function
  (after show-matching-paren-offscreen activate)
  "If the matching paren is offscreen, show the matching line in the
        echo area. Has no effect if the character before point is not of
        the syntax class ')'."
  (interactive)
  (if (not (minibuffer-prompt))
      (let ((matching-text nil))
        ;; Only call `blink-matching-open' if the character before point
        ;; is a close parentheses type character. Otherwise, there's not
        ;; really any point, and `blink-matching-open' would just echo
        ;; "Mismatched parentheses", which gets really annoying.
        (if (char-equal (char-syntax (char-before (point))) ?\))
            (setq matching-text (blink-matching-open)))
        (if (not (null matching-text))
            (message matching-text)))))


texts:
I am trying to spawn a shell outside emacs, not in a buffer.

I have tried (start-process "firefox" nil "firefox"), wich does start a firefox process outside emacs, but when i tried (start-process "bash" nil "/bin/bash") nothing seems to happen.


texts: A part of my .emacs sometimes takes effect, sometimes doesn't

texts:
A use Emacs 24 on an Ubuntu computer. The following are  parts of my .emacs file.

This is for activating flyspell:

(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(autoload 'flyspell-delay-command "flyspell" "Delay on command." t)
(autoload 'tex-mode-flyspell-verify "flyspell" "" t)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)

This defines a key binding for running Auctex Latex:

(defun my-run-latex ()
  (interactive)
  (TeX-save-document (TeX-master-file))
  (TeX-command "LaTeX" 'TeX-master-file -1))

(defun my-LaTeX-hook ()
 (global-set-key (kbd "C-c C-a") 'my-run-latex))

(add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)

This one raises the Emacs window when using Latex reverse search:

 (defun raise-client-frame ()
      (let ((wmctrl (executable-find "wmctrl")))
        (if wmctrl
        (start-process "wmctrl" nil wmctrl "-R" (frame-parameter nil 'name)))))
    ;; This raises the frame when using Evince.
    (add-hook 'TeX-source-correlate-mode-hook
          (lambda ()
            (when (TeX-evince-dbus-p)
              (dbus-register-signal
               :session nil "/org/gnome/evince/Window/0"
               "org.gnome.evince.Window" "SyncSource"
               (lambda (file linecol &rest ignored)
             (TeX-source-correlate-sync-source file linecol ignored)
             (raise-client-frame))))))
    ;; This raises the frame when using all other viewers.
    (add-hook 'server-switch-hook 'raise-client-frame)

The problem is that these three sometimes work and sometimes don't and this seems to be random. When they work, all three work and when they don't, none. Whether they work or not is somehow decided at Emacs startup but I don't know how.


texts: Three days ON one day OFF schedule in org-mode?

texts:
I'd like to set up a schedule for an habit such that the task has to be performed three days in a row and then skipped the fourth day. So, assuming the first recorded day is monday, I'll have:

Mon ✓
Tue ✓
Wed ✓
Thu x
Fri ✓
Sat ✓
Sun ✓
Mon x
etc.

Is it possible to set such a repeating schedule using the .+ syntax?


texts:
I often color in red some key-words in my latex-notes taken in Org-mode.

So I often end up using \textcolor{pink}{Blah Blah} all over my notes.

I would like to bind Alt+F12 to automatically expand into this snippet
with the cursor positioned on the second pair-of braces ready for input.

How would we do this?

I am using Spacemacs wrapped around emacs-24.5


texts: How to make M-x ansi-term behave like M-x shell (opening in new window)?

texts:
I use

(global-set-key (kbd "C-c a") '(lambda () (interactive) (ansi-term "/bin/bash")))

to open a bash ansi-term. Unlike M-x shell, this "occupies" the whole buffer/frame. I am wondering if one could adjust the above so that the ansi-term behaves like M-x shell in the sense of opening in a new window (in the current frame -- at the bottom, just like M-x shell does).


texts:
Why do some people use -- in their function names? Here's an example from elfeed-search.el:

(defun elfeed-search--header ()
  "Returns the string to be used as the Elfeed header."
  (if (eql (car elfeed-search--header-cache) (buffer-modified-tick))
      (cdr elfeed-search--header-cache)
    (let* ((header (elfeed-search--header-1))
           (cache (cons (buffer-modified-tick) header)))
      (prog1 header
        (setf elfeed-search--header-cache cache)))))


texts: Run the source code in org mode asynchronously

texts:
Upon running shell command from the org source code:

#+BEGIN_SRC shell
rsync -av ~/Documents \
    --include=~/Public  /media/me/disk/
#+END_SRC

it stopped and waiting, cannot do nothing else.

How could run the source code asynchronously?


texts: How to highlight a single word in comments, which matches a function call?

texts:
While there are packages that handle this, I would like to highlight a single word in source code comments, using for example the warning face, when a function call returns t, using the word as input.

How would this be achieved?


texts: package listed in `list-packages' but get `Error during download request: Not Found`

texts:
This is the value of my package-archives variable:

C-h v package-archives
package-archives's value is (("melpa" . "http://melpa.org/packages/")
                         ("gnu" . "http://elpa.gnu.org/packages/"))

When I do a M-x list-packages I see package js2-mode but when I try to install it I get:

Error during download request: Not Found

I also have the following in my .emacs :

 (use-package js2-mode
    :mode "\\.js\\'"
    :ensure t)

but when I visit a *.js buffer (with --init-debug) I get the following trace:

Debugger entered--Lisp error: (error "Error during download request: Not Found")
   signal(error ("Error during download request: Not Found"))
   error("Error during download request:%s" " Not Found")
  package-handle-response()
  package-download-tar(js2-mode "20151027.456")
  package-download-transaction((js2-mode))
  package-install(js2-mode)
  use-package-ensure-elpa(js2-mode)
  use-package-handler/:ensure(js2-mode :ensure t (:mode (("\\.js\\'" . js2-mode)) :config (t) :defer t) nil)
  use-package-process-keywords(js2-mode (:ensure t :mode (("\\.js\\'" . js2-mode)) :config (t) :defer t))
  #[(name &rest args) "\306^H\235?\205\317^@    ;\203^R^@\307   !\202^S^@       ^Z\310  ^H\"\311\312^[^\^]\313^M$
  (use-package js2-mode :mode "\\.js\\'" :ensure t)
  (progn (require (quote package)) (setq package-enable-at-startup nil) (mapc (function (lambda (p) (add-to-list$
  eval-buffer(#<buffer  *load*> nil "/home/mperdikeas/.emacs" nil t)  ; Reading at buffer position 25263
  load-with-code-conversion("/home/mperdikeas/.emacs" "/home/mperdikeas/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\313\307\314\315#\203*^@\$
  command-line()
  normal-top-level()

update

See my "answer" below.


texts: Change Emacs home directory for all purposes

texts:
I have my config files in ~/config/emacs which ~/.emacs is symlinked to.

I'm trying to figure out how to make the default "emacs root directory" $HOME in all contexts (unless overridden by a buffer-local variable), whether launching an ansi terminal, launching dired, or anything like that.

$ ls -al .emacs.d | perl -pe 's/^.*([.]emacs[.]d)/$1/'
.emacs.d -> ./config/emacs

My .emacs.d/init.el file contains the following snippet in an attempt to force emacs open stuff like dired and ansi-term in my home directory.

(cd (getenv "HOME"))

How do I change the effective root directory for ansi-term and everything else?

Here's a complete example that should reproduce the surprising behavior I'm talking about on OS X and Linux.

I have a directory ~/tmp/emacs

$ echo '(cd (getenv "HOME"))' > ~/tmp/emacs/cd.el
$ cd /tmp
$ emacs -q -l ~/tmp/emacs/cd.el

And then from inside emacs,

Launch the ansi terminal and accept the default shell

M-x ansi-term C-m C-m

print the current working directory from inside the terminal

$ pwd
/tmp

I expected working directory to be $HOME.


texts: Emacs flashes when changing buffer with `ido-switch-buffer`

texts:
When I change buffer via ido-switch-buffer and enter a python buffer my entire Emacs flashes visually for a second. If I handle other files the same way, it does not. What can be the reason for that? the related part of my config looks as follows

;; Turn switch-to-buffer into ibuffer
(global-set-key (kbd "C-x b") 'ibuffer)
;; expert-mode
;; If you feel like you know how ibuffer works and need not to be asked for confirmation after every serious command, enable this as follows.
(setq ibuffer-expert t)

;; * IDO
(setq ido-create-new-buffer 'always)
(setq ido-everywhere t)
(setq ido-auto-merge-work-directories-length nil)
(setq ido-enable-flex-matching t)
(setq ido-enable-prefix nil)
(setq ido-handle-duplicate-virtual-buffers 2)
(setq ido-max-prospects 10)
(setq ido-use-filename-at-point 'guess)
(setq ido-use-virtual-buffers t)
(setq ido-default-file-method 'selected-window)
(use-package ido-completing-read+ :ensure t)
(ido-mode 1)

;; ** IDO vertical
(use-package ido-vertical-mode
  :ensure t
  :diminish
  :init
  (ido-vertical-mode 1))
(setq ido-vertical-define-keys 'C-n-and-C-p-only)

;; ** IDO Switch buffer
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)


texts: In magit, is there a way to use user defined functions on global-map?

texts:
I updated magit today using el-get.

When I defined a function,

(global-set-key "c"
  (lambda () (interactive) (call-interactively 'self-insert-command)))

I couldn't use c c magit status buffer to commit. I get the following *message* buffer:

funcall-interactively: Buffer is read-only: #<buffer *magit-commit-popup*>
enter code here

Is there a proper way for user defined functions in magit?

Note that defining minor-mode doesn't solve my problem as I want to bind functions in global map.


texts: org-mode: specifying a hyperlink target as regex and jumping directly to match?

texts:
The documentation of a Fortran code, being done in org-mode, is intended to
be done in such a way that changing the Fortran source code to be documented
should be kept at a minimum.
There is the problem that text like "type t_obs", which is a definition,
does also occur in comments and is not unique.  A naive hyperlink
[[./obs.f90::type t_obs][obs.f90::t_obs definition]]
finds the first occurence in the file, which is not the desired one.
Specifying a line number in the link is not acceptable, as the code is
under development by a group other than those doing the documentation.
Specifying hyperlinks to match a unique target could be attempted using regular expressions, e.g. of the form [[file:~/xx.org::/regexp/]].
To be specific, I have tried the hyperlink:
[[./obs.f90::/^ *type t_obs/][obs.f90::t_obs definition]]
However, clicking on this link then opens an Occur buffer that shows exactly
one match.  It then requires to additionally click on the match in order to
jump to the link target.
Is there a trick to avoid the need for clicking on the match in the occur
buffer and immediately jump to this / the first match?
Furthermore, as my colleagures tell me, the above hyperlink with the regex
will not work properly in a PDF generated from the org file when viewed with
a PDF viewer.
Do I need to write a specific file-search-function, or is there an
easier way?


texts:
Up to this point, I used to have a separate configuration for each major mode, e.g. init.org.el, init.c++.el etc. I would invoke Emacs using an one of the aliases like these:

alias emacs-org='emacs -q --load ~/.emacs.d/init.org.el'
alias emacs-cpp='emacs -q --load ~/.emacs.d/init.c++.el'

At last, I got tired of having to run a different emacs instance every time I need to work with a different major mode, so I would like to unify my configuration.

I am thinking that the easiest way to do this is to put into init.el a hook for each major mode to load the corresponding configuration. So, init.el would have lines of the form:

(add-hook 'org-mode-hook (load-file "init.org.el))
(add-hook 'c++-mode-hook (load-file "init.c++.el))

I like this approach for the minimal number of changes that it requires. Also, having a hook in init.el, spares me from the need to put a lot of hooks in the files of individual modes.

However, there seems to be a problem. Namely, once say init.c++.el is loaded, all the configuration changes it performed will remain even when I switch to another mode... Is this correct? Is it possible solve this problem? And, more generally, is this approach to organizing configuration sound?


texts: mu4e query search for emails larger than certain size

texts: I've looked in all the examples given in queries of mu4e email but couldn't find an option that returns all emails larger than a certain size (for example 10MB). I think this is relevant if one is trying to free some space from his mailbox. Thanks in advance


texts:
When loading things like themes from custom directories, is it possible to specify a path relative to the init.el file, rather than an absolute path?

I ask because I want to be able to use the same config file across my OSX and Windows machines, where an absolute path like ~/.emacs.d/themes means something different on each machine (I'm not even sure how Windows handles ~)


texts: How to change mode-map of the minor mode?

texts:
I would like to change the mode-map of a minor mode with mode map.

I mean replacing the original mode-map that was specified in the define-minor-mode call with another one. Keeping the two mode-map unmodified.

How could I do that?


texts: elisp: retaining data structure after inserting string representation to buffer?

texts:
I'm currently writing a major mode (for interacting with a remote Grid Engine) which involves fetching data, parsing it into an alist, formating the alist into a string and then inserting the formatted string into a buffer.  This is done for many rows of data.

Now I want to add a way for users to interact with the data in the buffer, e.g. to tab from one field to the next, or to press RET on a field to invoke a function on it.

It seems silly to me to "lose" the underlying data structure after rendering it to the buffer.  Parsing the line at point (e.g. with (thing-at-point 'word)) to partially recover the data structure just seems like a bad idea.

Here's an example of one of these alists:

((job-id   . 123)
 (priority . 0.844)
 (name     . "some job name")
 (owner    . "rekado")
 (state    . "r")
 (time     . "2014-10-24")
 (queue    . "standard")
 (slots    . 12))

This may be rendered with a format string like this:

(defun format-job-record (job)
  (format ""%-10s %-10s %-15s %-10s\n"
          (cdr (assoc 'job-id   job))
          (cdr (assoc 'priority job))
          (cdr (assoc 'owner    job))
          (cdr (assoc 'state    job))))

Is there an alternative way (an idiom perhaps), that allows me to specify a way to display this alist while keeping the underlying data intact?  I would like to be able to retrieve the whole alist when point is on the row, and any given field when point is on the rendered text for the field.

I think this might be done by storing the alist as special properties on the generated string, and by storing the field keys along with each individual field string, but I'm not sure if this is the best way to do it.

My goal is to separate representation in the buffer from the underlying data and only work on data structures instead of text.

What is the most "natural" approach to achieve this?

EDIT:

Is there a better more "disciplined" approach than what is outlined in my answer below, or are custom text properties the idiomatic way to go?


texts: What's the proper new-style form for passing header args to all sql code blocks?

texts:
I guess I've been out of the loop for a while. I used to have this at the end of my org-mode SQL files:

#+PROPERTY: engine mysql
#+PROPERTY: dbhost xx.xx.xx.xx
#+PROPERTY: dbuser xxxxxx
#+PROPERTY: dbpassword xxxxxxxxx
#+PROPERTY: database xxxxxxxxxxxxx

But since I recently updated org-mode, these don't have any effect anymore. In ob-sql I can see they're not getting passed to org-babel-execute:sql.

I tried a different form that I saw in the doc:

#+PROPERTY: header-args:sql :engine mysql
#+PROPERTY: header-args:sql :dbhost xxxxxxx
#+PROPERTY: header-args:sql :dbuser xxxxxxx
#+PROPERTY: header-args:sql :dbpassword xxxxxx
#+PROPERTY: header-args:sql :database xxxxxxxxxxxx

but that doesn't work either. Can anyone tell me the proper new-style form for passing header args to all sql code blocks?


texts: Workaround bug#45038: 27.1; blank display

texts:
My setup: Emacs 27.1 under Ubuntu 20.04 from Kevin Kelley's PPA, and configured to use ligatures with the JetBrains Mono fonts, as described here.
I experiencing Bug#45038 27.1; blank display, or something very much like it.
On some modes (for example when I am trying to open my ~/.emacs.d/init.el file, when my window  is more than 115 columns wide, my screen go blank.
Using trial and error, I found that when I disable the auto-composition-mode this doesn't happen, however this also disables the ligature support.
So I am trying my hand at writing this workaround:
(defun my/wa-45038 (frame)
  (if (<= (window-width) 115) ; 115 found empirically
      (progn
        (auto-composition-mode 1)
        (message "auto composition on")
        )
    (auto-composition-mode 0)
    (message "auto composition off")
    ))

(if (and (window-system)
         (version<= "27.0" emacs-version)
         (version<= emacs-version "27.2")) ; It seems this will not be fixed in 27.2
    (add-to-list 'window-size-change-functions 'my/wa-45038)
  )

I can see it working (by inspecting the *Messages*), however this does not fix my issue, it seems that when I get a blank display my CPU is also pegged at 100% for the single core Emacs runs on,  and I suspect my code does not have the chance to be executed.
So my question boils down to: Is there a way to disable auto-composition-mode just before the new window size is set? If so, I will be able to conditionally re-enable it after the new window size was set with my workaround above.

Update: The high CPU load issue, that prevented this workaround from working, was probably due to me, messing up my configuration. I had both old and new code that tried to enable ligatures in different ways and most likely conflicted with itself. Removing the old code fixed the CPU load issue, and the workaround above is now working for me.
Note that the base question remains: Is there a way to [run a command] just before the new window size is set? But now it is mostly for intellectual pursuit.


texts:
I am using magit (2.2.2) with emacs 25.
magit is very good BUT I want the status dot in the modeline (like psvn does).

I try to use https://github.com/tsgates/git-emacs/blob/master/git-modeline.el with this configuration:

  (autoload 'git--update-all-state-marks "git-modeline" nil t)
  (add-hook 'find-file-hook 'git-status-in-modeline)
  (defun git-status-in-modeline ()
    (if (and vc-mode (string-match "^ Git" (substring-no-properties vc-mode)))
        (git--update-all-state-marks)))

When I open a file (under git) it doesn't work but if I do (revert-buffer) it works. Why the second time but not the first ? Any Idea to progress ?

  Thanks for any help.


texts:
I'm brand spanking new to taming the beast that is emacs. I'm using the built in "customize" feature (it has checkboxes and the like). However, when I save the changes, it does not prompt me where to save the .emacs init file. It saves it in a location I don't want, from which I had moved the emacs program upon installation.

PS any general tips are welcome. I am quite overwhelmed and hardly even know where to start!


texts: How do I control the directory that emacs starts in?

texts:
M-x dired = defaults me to C:\emacs\bin/

C-x d = defaults me to C:\home\files\

My init file is in C:\home\ and seems to work.

I have read the relevant manual sections several times, and I can't figure out what is going on here.

I want M-x dired to default me to C:\home\files\

I don't want anything to be going on in emacs\bin

How do I do this?


texts:
What should I use:
(when (package-installed-p 'ivy)
  (global-set-key (kbd "C-x b") #'ivy-switch-buffer))

or:
(when (fboundp 'ivy-switch-buffer)
  (global-set-key (kbd "C-x b") #'ivy-switch-buffer))

or:
(eval-after-load ivy ...)  ; haven't tested it yet

I try to rebind key based on a package presence. We are in 2021 so it is safe to assume of presence of package.el but what if I installed a package from git/hg?
UPDATE With fboundp & compilation of .emacs it doesn't redefine key.
Works with package-installed-p though... I haven't (ivy-mode +1) so function definition ivy-switch-buffer can be in form of autoload...


texts:
GNU Emacs 26.3
I updated all the packages and started to face with following error, I am not sure what is causing it, it wasn't happening before the update:
./icicles/icicles-cmd1.el :512:(eval-when-compile (require 'yow nil t)) ;; (no error if not found)

Debugger entered: nil
  (progn (debug))
  (if (equal (car (last (split-string filename "[/\\]") 2)) "obsolete") (progn (debug)))
  debug-on-load-obsolete("/usr/share/emacs/26.3/lisp/obsolete/yow.elc")
  run-hook-with-args(debug-on-load-obsolete "/usr/share/emacs/26.3/lisp/obsolete/yow.elc")
  do-after-load-evaluation("/usr/share/emacs/26.3/lisp/obsolete/yow.elc")
  require(yow nil t)
  (progn (require (quote yow) nil t))
  eval((progn (require (quote yow) nil t)) nil)
  #f(compiled-function (&rest body) "Like `progn', but evaluates the body at compile time if you're compiling.\nThus, the result of the body appears to the compiler as a quoted\nconstant.  In interpreted code, this is entirely equivalent to\n`progn', except that the value of the expression may be (but is\nnot necessarily) computed at load time if eager macro expansion\nis enabled." #<bytecode 0x1a5c47>)((require (quote yow) nil t))
  macroexpand((eval-when-compile (require (quote yow) nil t)))
  internal-macroexpand-for-load((eval-when-compile (require (quote yow) nil t)) nil)
  eval-buffer(#<buffer  *load*-881575> nil "/home/alper/.emacs.d/lisp/icicles/icicles-cmd1.el" nil t)  ; Reading at buffer position 24864
  load-with-code-conversion("/home/alper/.emacs.d/lisp/icicles/icicles-cmd1.el" "/home/alper/.emacs.d/lisp/icicles/icicles-cmd1.el" nil t)
  require(icicles-cmd1)
  eval-buffer(#<buffer  *load*-925687> nil "/home/alper/.emacs.d/lisp/icicles/icicles.el" nil t)  ; Reading at buffer position 84684
  load-with-code-conversion("/home/alper/.emacs.d/lisp/icicles/icicles.el" "/home/alper/.emacs.d/lisp/icicles/icicles.el" nil t)
  require(icicles)
  eval-buffer(#<buffer  *load*> nil "/home/alper/.emacs" nil t)  ; Reading at buffer position 56616
  load-with-code-conversion("/home/alper/.emacs" "/home/alper/.emacs" t t)
  load("~/.emacs" t t)
  #f(compiled-function () #<bytecode 0x1e0f5d>)()
  command-line()
  normal-top-level()


texts: Remember modes for files without extensions

texts:
I've started editing a lot of files that have no extensions, but are still in a major mode format.

I'm the only Emacs user on the team, and I don't want to make it a painfully obvious that my editor needs special stuff. I would like to avoid changing the codebase.

I can't change the filename
I can't use special Emacs comments

I would like Emacs to remember whatever mode I put the file manually in last (with, say M-x conf-mode) and automatically activate that mode when I visit it again.

I use savehist-mode to handle persistence.

Can I do this painlessly?


texts: emacs -nw set key-bindings similar to those of emacs-gui

texts:
In emacs -nw, many shortcuts are bound to something different from the "classical" emacs-gui. For instance:

\C-_ is bound to DEL  (classically it is undo)
backspace is \C-h thus opens help  (classically: DEL)
\C-backspace is bound to DEL  (classically: backward-kill-word)

I'd like to retrieve the ones I'm used to, so
following this and that, I've started this init file:
(normal-erase-is-backspace-mode 1)  ; fix backspace and del keys
(global-set-key "\C-_"     'undo)   ; redefine undo... doesn't work, requires a minor-mode, cf https://emacs.stackexchange.com/questions/352/how-to-override-major-mode-bindings
(global-set-key "\M-_"     'undo)   ; that'll do for the moment
; TODO: ctrl-backspace
;       any other?

But it seems I'm reinventing the wheel.
Isn't there already a solution? Probably in the form of a nox-compat-minor-mode?


texts: Use helm in specific modes and not for other buffers in different mode

texts:
I recently started using lsp-java and one of the packages it suggests is helm.
The suggested changes to the .emacs file to do this is:
(use-package helm-lsp)
(use-package helm
    :config (helm-mode))

This obviously works to start helm mode.
This issue I have is if I open another buffer in another mode (say shell in shell-mode)
it continues to use helm which I really don't like.
I have tried adding the helm-lsp and helm mode initializing into a function which in turn is loaded via a java-mode-hook:
(defun init-lsp-java-stuff ()
       (interactive)
       ...
       (use-package helm-lsp)
       (use-package helm
           :config (helm-mode))
       ...
)
...

(add-hook 'java-mode-hook 'init-lsp-java-stuff)

This works if I never enter java mode, but still after entering java mode all my other buffers have helm loaded.
What I want is for helm to ONLY be loaded for java-mode buffers, and NOT be loaded for buffers in any other mode.


texts: Syntax highlight the opening parenthesis line printed in echo area

texts:
With respect to this answer, is there any way to enable syntax highlighting for the text printed in echo area by blink-matching-open? I am asking for something similar to what Lua Block mode does.

For reference, this is the current behaviour:


texts: Org babel R: why is 'NA' replaced with 'nil'

texts:
When using R in org mode source blocks, any NA (i.e. missing) values in tables get replaced with nil. Why is this?

And is there a way to change this (globally, or at the file level)? I regularly create reports using Org Babel that are to be read by non-Org users and while they do understand NA, nil means nothing to them.


texts: Javascript mode mixes tabs and spaces for indent

texts:
My javascript mode indents with a mix of tabs and spaces. I'm ok with the mix if spaces are used for cosmetic alignment, but this is just wrong:

First level of indentation is spaces, second is tab, third is tab and spaces.
I tried looking for relevant variables. js-indent-level is 4.
This is this way with emacs -q as well (just using my config above for illustration purpose).
How do I fix this, preferably using spaces only?
Emacs 25.2.2

EDIT: Yeah, so I can set indent-tabs-mode to nil, but isn't the behavior with it at t still wrong?


texts: How to use AUCTeX and outline-minor-mode together for folding?

texts:
I'd like to easily hide or show the text below individual headings in a large Latex document.

I thought this should be possible with outline-minor-mode, however I can not get it to work. I can activate the mode, but I don't see how to hide or show something.

The AUCTeX documentation says that AUCTeX can work together with outline-minor-mode.

I also looked at the documentation on Outline Mode, but

motion commands do not have any effect (and seem to conflict with AUCTeX keybindings)
same for folding commands

When using AUCTeX folding commands like C-c C-o C-b for folding the whole buffer, only some labels and small things are hidden, but not enough.

I'm familiar with using org-mode, so it would be nice if I could use key bindings similar to org-mode's for expanding/collapsing sections or navigating between headings.


texts: Help dealing with Async sleep for "Simulated Typing" effect

texts:
I am trying to build a function, that takes a body of text from a buffer or a file, and "simulates typing" in another buffer. This will serve me towards recording programming videos where the code appears to be written in real-time.

The main issue I am dealing with is the delay which needs to happen between each character printed.  I have tried using timers such as run-at-time and async-start with sleep-for events.

run-at-time is printing every character from the string after the chosen delay, despite being inside a dolist.

I am quite a noob on Elisp, maybe someone could give me a hand? I am using Spacemacs. If someone is wondering, the effect that I want to achieve would be something similar of the youtuber Biskwit, but much simpler of course. Here


texts:
I found that refiling a subtree to another file does not move
footnotes.  Does that have to be done manually, or is there a feature
that has to be turned on?


texts: How to expand abbrevs without hitting another extra key?

texts:
How can I expand oe to ö immediately after hitting the e without hitting any extra key like space for expansion?

Why? For better ergonomics I've remapped some keys like ö, ü and thus must write them with oe and ue.


texts:
I went to start emacs today and was greeted with this:

WARNING: No org-loaddefs.el file could be found from where org.el is loaded.

followed by

You need to run "make" or "make autoloads" from Org lisp directory

Any idea how I can fix this error?


texts: Preview images, and PDFs inside a SSH terminal session or inside emacsclient session via SSH?

texts:
I work remotely to Linux servers, writing R scripts with ESS. Rstudio works well if I have a fast and stable GUI-based remote desktop connection to the server. Rstudio server also works OK if I have the server running and now problems with managing logins. However, these two choices are not available on the server. So, Emacs+ESS is a great choice for code editing experience. The catch is, I will have to download generated images and PDF to my local computer to see them. That is not a workflow I want to do every couple of minutes. Doing a SSHFS mount to local computer is a better, but is still not the workflow I want. The ideal workflow:

Write code in an emacsclient inside a tmux session
Run code to generate plots, or PDFs from Rmarkdown
Preview the files right afterward inside the emacsclient window, or in another tmux split, or Window.

This threads discusses various options to view images in the terminal. There is pdf-tools package for emacs to preview PDF documents. So, I believe it is technically possible at the moment. But I don't use emacs so frequent these days so my reflex is a bit rusty. Some guidance/demo setup code will be really appreciated.


texts: error message when previewing latex snippet in .org file

texts:
I am a brand new emacs user and I want to be able to view snippets of LaTeX in my .org file.

My OS is Ubuntu 16.04, I have installed texlive-full, and I have installed AucTex and org using the Emacs package manager.

I have been trying to follow the first example in this guide:

latex preview example

I have put in my .emacs file the single line

(setq org-latex-create-formula-image-program 'imagemagick)

I have the imagemagick package installed in Ubuntu.

Yet when I try to see the first example by pressing C-c C-x C-l, I get this error message:

org-compile-file: File "/tmp/orgtex32228nYH.pdf" wasn't produced.  Please adjust 'imagemagick' part of `org-preview-latex-process-alist'.

When I press C-h v I can inspect the variable, but I have no idea what to change...

Looking in /tmp there is no corresponding .log file, only a .tex file, which doesn't reveal any error.

Can anybody please help me?


texts:
I'm currently using Flyspell to auto-correct the previous word as I type, which is convenient. However, the spell-checker I use, Hunspell, makes some strange decisions.

For example, the misspelled word "hte" is corrected in the following order:

  hate HT ht GTE the ...

when it's obvious (at least to me!) that the first correction should be "the"!

I'm not sure whether this is a Flyspell problem or a Hunspell problem. Is it because Flyspell (which, as I understand it, uses ispell behind the scenes) does not get enough context to do a better spell correction, or because the Hunspell dictionary is not good enough?

What's a better way to automatic spelling correction in Emacs?


texts: Make 'ctags' detect fortran's "module procedure" pattern?

texts:
I am using ctags to index fortran files for code navigation in Emacs with M-..

In doing so I have noticed that it doesn't recognize declarations of the form

MODULE PROCEDURE MySubroutineName   ! or
MODULE SUBROUTINE MySubRoutineName

which arise when using the SUBMODULE feature.

In "https://stackoverflow.com/questions/3497538/ctags-and-fortrans-interfaces" a similar issue occurred, but there the solution was merely to enable a feature, that isn't enabled by default. For submodules no such feature exists.

Is it possible to make ctags aware of this construct?