texts: Wait for result of fzf without blocking input

texts:
I'm trying to make use of the fzf fuzzy finder to search through a list via a term process. The way I do this is very similar to fuzzy-finder.el or fzf.el. This is by launching fzf with:
(progn
  (advice-add 'term-handle-exit :after #'after-term-handle-exit)
  (switch-to-buffer
   (make-term "*fzf*" shell-file-name nil shell-command-switch
          "fzf"))
  (term-char-mode))

This allows the user to type normally as if they were working with the fzf process directly. When the process exits, the selected value is parsed using the term-exit-handler by looking for the first line in the buffer beginning with " >":
(defun after-term-handle-exit (proc-name msg)
  (let* ((lines (split-string (buffer-string) "\n"))
     (selects (-filter (lambda (s) (string-match-p "\s*>\s+" s)) lines))
     (choice (string-trim-left (car selects) "\s*>\s+")))
    (setq fzf-result choice)))

This all works fine and sets the variable fzf-result just fine but what I would like to do is make the progn wait for the process to finish and then return the result. Normally I think this would be fine because I could just spin until fzf-result is non-nil but in this case fzf needs input from the user (via emacs) and so such a method just results in a freeze.
I know I could use a callback but I want to avoid this if at all possible. I was wondering if there is a way this could be achieved with threads? Or by explicitly passing keyboard inputs to the process?
Thanks for any advice


texts:
Windows 10
Emacs 26.1

Here example of my org file with many inner items

In my opinion it does not look very comfortable.
I think asterisks make "noise". Is it possible to remove asterisks?


texts: shell-script mode: set local vars for indentation

texts:
I have a shell script that uses 2-space indentation, like this:

#!/bin/bash

function foo() {
  echo "Hello world"
  echo "Nice to see you $1"
}

foo Tony

Emacs default indentation for shell is 4-space. I have been trying to specify local variables to change the indentation to 2-space, but failed. This is the extra stub I added at the end for the script above (that did not succeed):

# Local-variables:
# sh-indentation: 2
# sh-basic-offset: 2
# End:

Before doing this local variable thing, I tried to customize emacs using Programming -> Languages -> Sh -> Sh Script -> Sh Indentation -> Sh Basic Offset. If I set this variable to 2, and open the shell script, it did indent that script to 2-space.

On the other hand, the exact same Emacs could do it for a Python script, simply with this kind of stub at the end of that Python script:

# Local-variables:
# python-indent: 2
# End:

Can someone help me through this?

Wirawan


texts: byte compiler warning: called with 2 arguments, but accepts only 1

texts:
When I byte compile an elisp file via emacs -batch -f batch-byte-compile I get Warning: load-theme called with 2 arguments, but accepts only 1. The code in question:

(load-theme 'solarized-light t)

The source in Emacs 25.1's custom.el: (defun load-theme (theme &optional no-confirm no-enable) ...

Similarly I get set-frame-font called with 3 arguments, but accepts
    only 1-2 when set-frame-font's help says: (set-frame-font FONT &optional KEEP-SIZE FRAMES)

Which is confused, the byte compiler or I; and why?


texts:
If I create a bad [[file:link]] or an internal [[Link]] that does not exist, I would like to org-mode to fontify this using org-warning face. How can I get this done?

Thanks,


texts: Create term buffer duplicate with coloring preserved

texts:
I want to write function that will create new empty buffer, populates it with current term buffer contents, preserving point and window-start positions, and switch to it right away. Basically I want to make my own term-line-mode. Function below do it all great, with only problem that its not preserving coloring of term buffer:

(defun sandric/duplicate-current-term-buffer ()
  (interactive)
  (let ((duplicate-buffer (get-buffer-create "NEWBUF"))
        (term-point (point))
        (term-window-start (window-start))
        (term-overlay (make-overlay (point-min) (point-max))))
    (copy-to-buffer duplicate-buffer (point-min) (point-max))
    (switch-to-buffer duplicate-buffer)
    (set-window-start (selected-window) term-window-start)
    (goto-char term-point)
    (move-overlay term-overlay (point-min) (point-max) duplicate-buffer)))

I know nothing about coloring in emacs, and how its actually works, as I understand, it is done via overlays? So in that code I tried to get current term buffer overlay and copy it to newly created duplicate buffer. But I see no color. Can anyone explain how should I tackle this?


texts:
I just spent a significant amount of time debugging an issue that boils down to the following:

(defun my-new-alist ()
  `((x . nil)))

(setq a (my-new-alist))
(setq b (my-new-alist))

(push 1 (alist-get 'x a))
b ;; ((x . 1))

I expected a and b to be independent of each other (that is, I expected my-new-alist to be pure. Instead, it seems to create a new list when the defun is executed, and always return a reference to that very list. Part of my confusion stems from comparing with the following:

(defun my-new-list ()
  nil)

(setq a (my-new-list))
(setq b (my-new-list))

(push 1 a)
a ;; => (1)
b ;; => nil

Note also that anti-quoting the nil part fixes the issue, it seems; that is, the following function doesn't exhibit the problem:

(defun my-new-alist ()
  `((x . ,nil)))

What is the significant difference between the list and alist examples? Which parts of the ELisp manual discuss this issue? Why does antiquoting the nil part fix things?

This question is similar to, but not the same as, Proper reinitialization of a list? What is happening under the hood?. The answers to that question doesn't discuss why using nil isn't a problem, nor do they explain why antiquoting nil makes a difference. Additionally, I am looking for references in the Emacs lisp manual.


texts: Why can't AucTeX see my TeXLive binaries? (Cygwin on Windows 7 x64)

texts:
I have installed the TeXLive distribution. From emacs running in cygwin mintty, the LaTeX binaries are visible from my PATH environment variable. I installed AucTeX using the built in Emacs package manager with the package from Elpa.

$ which latex
/cygdrive/c/texlive/2016/bin/win32/latex
$ which pdflatex
/cygdrive/c/texlive/2016/bin/win32/pdflatex
$ latex
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/W32TeX) (preloaded format=latex)
 restricted \write18 enabled.
**

However, when I try C-c C-c from a LaTeX file, I get the following message:

TeX-command: ERROR: AUCTeX cannot find a working TeX distribution.
Make sure you have one and that TeX binaries are in PATH environment variable

Is there some AucTeX variable I could customize to point it in the right direction to the TeX distribution? I am pretty confident my PATH is set correctly.


texts:
I'm looking for a multiple-major-modes package that doesn't remove fontification of the host mode from its inner submodes?

I tried MMM Mode and Polymode, but they remove the initial fontification and put own faces with own background colors in regions with submodes.

What I'm trying to achieve is to fontify diff hunks in diff-mode syntactically according to the rules of their source code language, e.g. to highlight their keywords like it's done on diff pages of version control web sites like github/gitlab.

multiple-major-modes packages are able to detect diff hunks and their source language from file extensions in the diff header, find the corresponding major mode using auto-mode-alist, and fontify these diff hunks accordingly as submodes. But they don't keep fontification of diff-mode with faces diff-added and diff-removed that highlight changes using different background colors.

Is there a package that can do this?


texts: Emacs does not use swapped alt&win after xmodmap runs? (GUI emacs)

texts:
I have a mac-book-air. I swapped my Alt  & Win with xmodmap as per linux post like so:

keycode 64 = Alt_L
keycode 133 = Super_L
remove Mod1 = Alt_L
remove Mod4 = Super_L
add Mod1 = Super_L
add Mod4 = Alt_L

Then I apply it via:

xmodmap xmodmap.file

Now my Alt+tab works properly, but in Emacs meta(alt) and Super(cmd) are not swapped. I.e, s-x and M-x are not swapped. After 3 hours of googling around I've not made more progress.

Do you have any tips/advise/things to try? (I'm very desperate).
Is it possible to re-map these from inside emacs itself?

Background:
 - I'm using MATE Desktop.
 - I tried Gnome Tweak Tool to swap alt & cmd, but it doesn't seem to function under MATE Desktop.

[Edit]
- This issue occurs only in GUI version of emacs. In terminal it get's the right keys.
- I have tried re-starting emacs, restarting system, applying the change then start emacs. No Luck.


texts: Emacs / Projectile complains about no job control with Bash/terminal

texts:
I use Emacs 27.0.50 on Ubuntu 18.04. Fish is my default shell.

When a file from a directory with .git is being loaded into the buffer, I'm trying to start projectile-find-file  , I see the following error output:

(file-missing "Setting current directory" "No such file or directory" "/home/renefroger/[directory of file]/bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

When I'm googling on this, I see the following issue which might be related to my issue: https://stackoverflow.com/questions/9471341/emacs-shell-command-outputting-cannot-set-terminal-process-group-and-no-job-c/9500684

But in my .emacs the following is already declared:

(set-variable 'shell-command-switch "-ic")

When I add the following in my .emacs

(setq shell-file-name "fish")

and restart Emacs, this makes no difference. I get the same error from Projectile. When I change the default shell for my user with chsh --shell /bin/sh renefroger, this makes no difference after restart.

So I'm not sure why Projectile still complains he can't interact with my Bash (I use Fish as my default shell, by the way). When looking into Projectile variables, I can't find any shell-related command/variable, and nobody in the Projectile Github repository seems to have this issue.

Perhaps anyone here knows how to tell projectile how to interact with my shell?


texts:
I come from Java/Netbeans, and I can indent my Java code using alt+shift+f,
I have searched through this site and other articles, but I didn't find a good way to indent PHP.

What I found:

  using pear PHP_beautifier

but I have to output the result to a different file or simply copy on terminal result.

  using PHP beautifier on the web

I have tried using M-x indent-region in PHP-mode but nothing changes. I tried in jdee for Java code M-x indent-region also doesn't work.

I found other solutions but for JSON, com.lang, Asytle (C/C++/C#)

this is my .emacs

https://gist.github.com/azzamsa/1f76b8ca00fd2737ae08a5c3f6dc6b3f

I am using :

php-mode-1.18.2(ejmr/php-mode), GNU Emacs 24.4.1

and installed php-mode from elpa repo.

After following phils suggestion to use Tab, it works. But when I try to break the code format, and try to see the result using C-x+ h and Tab, it doesn't indent the code properly as what online formater does. e.g.:

    public function

        __construct($name) {
        $this->name = $name;
        //$this->numLeg = $numLeg;
    }

    public

        function

            bark() {
            return "Woof!";
        }
    public

        function

            greet() {
            return "hello i am " . "$this->name";
        }

}

There is no result even when I use indent-region. I also tried to use fill-region, and other choice of fill, but no luck. But the online formatter can handle this nicely, the result from online formatter and the expected one is:

class Dog {
    public $numLegs = 4;
    public $name;

    public function __construct($name) {
        $this->name = $name;
        //$this->numLeg = $numLeg;
    }

    public function bark() {
        return "Woof!";
    }
    public function greet() {
        return "hello i am " . "$this->name";
    }

}
$dog1 = new Dog("Barker");
$dog2 = new DOg("Amigo");


texts: How to define an image as a display-table entry

texts:
Is there any way to create a custom image (e.g., using an xpm format) and use it in the display-table?

I see that XEmacs had a function called make-glyph -- e.g., (make-glyph '([xpm :file "~/something.xpm"] [string :data "[END]"])).  However, regular Emacs doesn't have that function.

The function make-glyph-code requires a character (e.g., ?\U0001D4D5) -- and there is an optional face argument (e.g., 'font-lock-warning-face).

I would like to do something similar to:

(when (not buffer-display-table)
  (setq buffer-display-table (make-display-table)))

(aset buffer-display-table ?\014 form-feed)

(defvar form-feed `(image :type xpm :mask nil :ascent center :data
  "/* XPM */
  static char * form_feed_xpm[] = {
  \"11 20 5 1\",
  \" c None\",
  \". c purple\",
  \"+ c yellow\",
  \"@ c #7F0000\",
  \"% c yellow\",
  \"%%%%%%%%%%%\",
  \"%.........%\",
  \"%.........%\",
  \"%.........%\",
  \"%.........%\",
  \"%...++++++%\",
  \"%.++.++...%\",
  \"%+...+....%\",
  \"%+...+....%\",
  \"%+...+....%\",
  \"%+...++++.%\",
  \"%....+....%\",
  \"%...++....%\",
  \"%...+.....%\",
  \"%.++++....%\",
  \"%.........%\",
  \"%.........%\",
  \"%.........%\",
  \"%.........%\",
  \"%%%%%%%%%%%\"};"))

EDIT:  As a first impression, it seemed that the library gamegrid.el might have been using the concept outlined above.  However, it turned out that gamegrid.el uses the buffer-display-table as a buffer-local storage facility for the xpm images, which are later used by the function gamegrid-set-face to add-text-properties using the 'display property.  While it was a good excuse to play pong and tetris, it did not resolve this particular question.


texts:
I'd like to transform:

function arg(a,b,c){}

to

function arg( a, b, c ){}

Is there a way to do this or set it as part of c style auto indentation? So it will happen when editing JavaScript, C++, etc?


texts: More detailed org-capture into org-table template?

texts:
(Disclaimer: I know this may seem like a very specific question. But: I haven't found the answers to similar questions to be close enough to what I need. I hope to get an answer that is easily understood, and that people can adapt to their own needs, without having learned elisp)

I have an already existing table, that I want to append rows to with org-capture

The workflow I want:

Shortcut pressed
Menu pops up asking "Should this be an internal link?". Answer with y/n

If yes, the name-field in pt. 3 should be this:

[[#PLACEHOLDER-NN] [Name]]

PLACEHOLDER is just the text "PLACEHOLDER". I'll fill that in later
- is an actual hyphen
NN is the next custom-ID-number. I use the "name hyphen incremented_number"-format to avoid having identical custom IDs

Right now, I use a one-liner to find the highest number used so far. Shown at the end of the post.

Space between to prevent emacs from smooshing the link together, so that I can see which PLACEHOLDERs need replacing. I'll remove the space by hand after replacing the PLACEHOLDER.
Name is the name of the project

Else: The name-column is just text entered by me

Press enter
Get to the next column, titled "2 Comment"
Enter Comment-content. Might be empty. Hit enter to skip
Hit enter when finished entering comment
Get to "3 Tags"-column
Enter tags
Hit enter to get to next column. Skipping column #4
Enter contents into 6 more columns
When that's done, perform the calculation (#+TBLFM: $4=($5+$6+$7+$8-$9-$10)) right underneath the table
Table is resorted by column titled "4 Total". Header- and separator-row stay where they are

Answer to similar thread: Org capture into org table - I don't know enough elisp to modify it to my needs

Possibly complicating factors:

My table isn't right under a top-level heading. There's a top-level heading, some text, a blank line, and then the table
I have that calculation right underneath the table

One-liner:
grep ^\ *:CUSTOM_ID: ~/Path/To/file.org | awk '{print $2}' | awk -F '-' '{print $2}' | sort -n | tail -1

  Searches for lines that start with 0 or more spaces, then have the phrase ":CUSTOM_ID:", as in the start of an internal link. The next argument specifies which file it searches through. Then awk first displays only the 2nd field (the custom ID itself. We're not interested in the phrase ":CUSTOM_ID:"). Then awk uses a hyphen as a separator, and prints only the 2nd field there: the numbers after the hyphens. Now that we have these numbers, we can numerically sort by them, and use tail -1 to display just the last (and largest) of these numbers. The next number should be largest-number + 1


texts: Simple way to test if string contains float eg. "8.3"

texts:
I thought (defun string-integer-p (string) was cool,
I found it in the emacswiki.

Is there a variant of it I can use to test if string contains float eg. "8.3"


texts: Change font or point colour based on absolute path of the source file

texts:
This is a rare occasion when I need it, but I am trying to figure out a way to change colour of font/point based on the path of source file to easily distinguish which file I am editing when I am working on two similar repositories.

(E.g. based on files from /some/path/local_master and /some/path/remote_master).

Any advice?


texts: Emacs relative and absolute line number at the same time?

texts: I don't mean hybrid line number mode, I want the absolute line number appears for all the lines, not only the current line number.


texts:
I am new to Emacs, I use text Emacs (inside Putty) and I am from Vim land. So, bare with me about the terminologies that I use.

I want to have a custom string in the mode line for the frame name (to remember why I created this frame) as the defaults like "F6" is of no use to me.

I found how to create new frame and set-frame-parameter  from gnu.org. I gave a try to create new frame from elisp (the first link):

(setq x '(("name" . "parsing")))
(make-frame x)

But the frame it created has the name F6. I checked it executing (frame-list) (shown in picture above).
What am I doing wrong here? Is there an easy way?


texts:
This has been driving me crazy, I can't get this to work. I want to link the on-off status of a handful of minor modes, in particular evil-mode, evil-quickscope-mode, hl-paren-mode, and a few others. I don't necessarily want evil globally, but once I turn on evil-mode I want the other modes to also turn on (and correspondingly turn off once evil turns off).

Is there a way to accomplish this cleanly? The closest I've come involved using mode-hooks, but somehow the modes always got out of sync (evil on, others off. others on, evil off. etc.)

edit: Posting the relevant mode-hooks section of my init.el:

;; Evil Mode Setup
(require 'evil-leader)
(evil-leader/set-leader ",")
(evil-leader/set-key "q" 'kill-buffer-and-window)
(evil-leader/set-key "b" 'ibuffer)

(defun after-all-loads () (require 'evil))
(add-hook 'after-init-hook 'after-all-loads)
(define-key global-map "\C-xv" 'evil-mode)
(add-hook 'evil-mode-hook 'hl-paren-mode)
(add-hook 'evil-mode-hook 'evil-visual-mark-mode)
(add-hook 'evil-mode-hook 'evil-quickscope-mode)
(add-hook 'evil-mode-hook 'evil-leader-mode)


texts: how to include gif images in org-export to LaTeX?

texts:
When I export from org-mode to PDF via LaTeX, my jpg images export successfully, but my gif images do not appear. The gif images do export when I export to HTML.

I found a variable called org-export-html-inline-image-extensions, which is set to "png" "jpeg" "jpg" "gif" "svg" "tif" "gif". However, I don't find an analogous variable for LaTeX.

Closest thing I could find is org-latex-inline-image-rules, but adding gif to that had no effect on export.

How do I direct org-mode to include gif images in export?


texts: restore cursor position iedit mode after narrowing with evil visul line

texts:
Iedit-mode can narrow the edit to a region, I am using evil-mode, evil-visual-line select region by whole lines, after narrowing the point is at the end of last line, is it possible to fix this jumping and make it stay at the symbol's column? I have tried the following:

(defadvice iedit-mode (around iedit-around)
"fix cursor position"
(save-excursion ad-do-it))
(ad-activate 'iedit-mode)


texts: Use ssh-agent's SSH_AUTH_SOCK value, not macOS' one

texts:
When I run (getenv "SSH_AUTH_SOCK"), I get "/private/tmp/com.apple.launchd.K9OEFgxDgw/Listeners".

I want to set it to the value that is returned by echo $SSH_AUTH_SOCK on the command line which is something like /tmp/ssh-P7OPvY12nTFk/agent.35299

Unfortunately, (shell-command-to-string "echo $SSH_AUTH_SOCK") also returns "/private/tmp/com.apple.launchd.K9OEFgxDgw/Listeners".

How can I set SSH_AUTH_SOCK to /tmp/ssh-XXXXXXXXX/agent.YYYYY?

The background is that I want Magit to be aware of the SSH agent I'm running  so I can connect to Bitbucket repositories.

EDIT: I solved my problem by using the Keychain tool and keychain-environment for Emacs (see this answer by the Magit author).


texts:
Say I have the following text:

A. U. Thor writes:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam est
elit, pulvinar sit amet erat nec, finibus sagittis ex. Mauris
dictum elementum est in fringilla? Duis vel dui elit! Praesent
tincidunt velit vel ipsum facilisis fringilla! Donec tincidunt
pulvinar nulla eu convallis. Sed venenatis non risus nec
tincidunt: nam volutpat mauris elementum tortor posuere
tempus. Nam varius aliquam rhoncus. Praesent commodo odio sed
tristique volutpat. Fusce eu mauris consequat, porta nulla ut,
vestibulum neque? Mauris tincidunt elit quis convallis imperdiet.

Nulla ac porta lectus. Nullam faucibus eu orci in porttitor? Sed
imperdiet cursus venenatis. Nullam eu est nisi: cras accumsan
rutrum sapien, sed maximus nisl pulvinar id. Nulla sollicitudin
sollicitudin neque, in rutrum tortor malesuada quis. In interdum
nec lacus id cursus. Pellentesque condimentum tortor at nisi
fermentum, ac aliquam nunc laoreet. Aenean faucibus orci nec
vehicula facilisis. Donec at metus enim? Nam vel sapien
tortor? Aenean non nibh congue, lacinia tortor posuere,
consectetur mi: integer quis eleifend lectus. Suspendisse vitae
ligula vel ante rhoncus ullamcorper non at urna. Praesent
sollicitudin ut purus non pellentesque.

Sed convallis metus ut ipsum ultricies bibendum? Phasellus vitae
mattis magna. Ut vel ex purus. Phasellus pellentesque diam vel
erat dapibus hendrerit. Ut pretium erat sed sapien tempus, eu
auctor lorem facilisis. Sed eu malesuada turpis. Quisque ac leo
mollis, molestie purus convallis, convallis sem? Sed tortor diam,
efficitur sit amet magna nec, volutpat mattis tortor? Suspendisse
varius neque non mattis pretium? Vivamus ac rhoncus ipsum? Nunc
pellentesque lobortis purus. Proin interdum venenatis augue at
venenatis. Integer in hendrerit urna, vitae commodo
massa. Phasellus nec feugiat ex, sit amet posuere elit.

In hac habitasse platea dictumst. Morbi id velit neque. Nulla
facilisi: sed et enim ut velit accumsan facilisis. Praesent
rhoncus vel sem vitae ullamcorper? Sed tincidunt tincidunt
nunc. Cras egestas urna turpis, at malesuada risus elementum eu.

Curabitur ultricies, erat ut consectetur malesuada, massa ante
iaculis lectus, vitae convallis nibh elit eget dui: sed malesuada
dui eu ipsum luctus tincidunt at ac sapien. Donec lorem ligula,
porttitor non sem vitae, auctor suscipit elit. Sed iaculis ex id
fringilla auctor? Aliquam quis dignissim leo. Sed tincidunt massa
vel justo vehicula vehicula gravida nec metus. Integer euismod est
vitae hendrerit vestibulum? Vivamus condimentum ornare
felis. Aliquam fermentum a diam non pulvinar?

Is there an easy way to double all the sentence-ending spaces?  I can't think of a way to detect the length of the 'sentence' it terminates before doubling the space, let alone ignore common prefixes like Mr, Ms, and Mrs.


texts: How to align specific columns, for several lines simultaneously?

texts:
Consider i want to make something like this

row one goes like this
row two goes like this
woops like this
woops like what happend now

and i want the like to be aligned in all sentences, something like this:

row one goes like this
row two goes like this
woops        like this
woops        like what happend now

Now imagine i want to do this for 100+ lines, is there a way to indent my lines effective without having to go through every line?

I have tried M-i, which is perfect for 1 row, but i can't figure out the vertical aligning part,


texts:
I'm currently working on a CHIP-8 emulator. This platform requires me to draw 64x32 black/white pixels, ideally at a speed between 30 and 60 frames per second. There's an extension to it that increases the possible resolution to 128x64 black/white pixels. At this speed I've found it necessary to avoid needless consing, this severely limits my options.  My experiences so far:

Generating SVG on the fly. My preferred library for this keeps creating tons of lists. The alternative would be using a template string, however I'm afraid editing it will create new strings, creating a comparable amount of garbage in the process.
Inserting lines of colored text, then moving across them and deleting/inserting differently colored text if needed. This is my current approach.  It works fast enough at 64x32 pixels, but turned out to be too slow at 128x64 pixels.  I can imagine that changing the properties of text might help, but haven't tested it yet.
Inserting a XBM image backed by a bool vector, then changing the bool vector's contents and forcing Emacs to redraw the image.  The latter part is particularly painful as you need to (force-window-update BUFFER) and (image-flush SPEC) to make changes happen. Furthermore, not all changes are visible for a yet to be determined reason, the overall experience isn't nearly as smooth as with the previous solution.  If drawn at a scale comparable to the text solution, the speed is in fact a bit worse.  I've yet to test it at 128x64 pixels.

Are there any other possible solutions or tweaks I've overlooked?  I'd prefer to stay within the options of vanilla Emacs before venturing into creating my own C module for creating a canvas I can quickly paint to...


texts: Display images in eshell with `iimage-mode`

texts:
My default shell is eshell.  I just discovered iimage-mode that allows me to display images in buffers that contain some reference to an image file.  Unfortunately, I doesn't seem to have any effect when it is enabled in eshell.

In any other buffer something like file:///home/rekado/Pictures/test.png is replaced with an inlined image loaded from the file test.png.  In an eshell buffer, however, I cannot seem to make this work.

I tried echoing the string file:///home/rekado/Pictures/test.png, but this just results in a boring string and no pretty test image.  I also made sure to use /bin/echo instead of the elisp/eshell implementation of echo, but with no success.

When I disable and reenable iimage-mode it works all right (the file name is replaced with an inline image), but that's a rather inconvenient workaround.

If there's no way to make eshell work with iimage-mode maybe there is another method to display images right in the eshell buffer?


texts: Emacs config file when installed using snap

texts:
I installed Emacs 26 on Ubuntu using snap.

Where to find the Emacs configuration file in this context ?


texts: How to highlight preceeding space-indentation that isn't rounded to current width?

texts:
Is there a way to highlight (set the background color for example) the space before a line, when it's indentation isn't aligned to the current indentation-width?

4 spaces indentation for eg:

fn my_func() {
    if foo() {
        ##bar();
        blob();
    ###fez();
        baz();
    }
}

where the # characters represent the background showing a different color, back until the indentation is aligned to 4.

Of course this is only useful when code follows strict indentation conventions.

Note that I'm aware of emacs advanced auto-indentation features and indent-highlighting plugins, but would prefer something less intrusive that only shows up when there is an issue. A little like highlighting trailing spaces.


texts: org-download-screenshot from pdf-tools with renaming according to pdf name and pdf page

texts:
I would like to use org-download-screenshot (or some other function) in combination with pdf-tools.
This works quite well out of the box. What I am missing is a enhanced renaming of the screenshot.
That means, the png file should should be placed in the subdirectory ./img and be renamed according the name of the pdf file (e.g. first 10 characters) and the page of the pdf.
An alternative which I am using is on macos is this function
(defun screenShot_org()
  (interactive)
  (if buffer-file-name
      (progn
        (message "Waiting for region selection with mouse...")
        (let ((filename
               (concat
                (read-file-name "Enter PNG Name:")
                "_"
                (format-time-string "%Y%m%d_%H%M%S") ".png")))
          (call-process "screencapture" nil nil nil "-s" filename)
          (insert (concat "
#+NAME:
#+ATTR_ORG: :width 200
#+ATTR_LATEX: :width 0.9\\linewidth
[[file:img/" (file-name-nondirectory filename)"]]"))
                    )
        (message "File created and linked...")
        )
    (message "You're in a not saved buffer! Save it first!")
    )
  )

This basically asks for the file path and first part of the name, but does not recognize the pdf file name nor the pdf page number.
I hope it is clear, what I want to achieve...


texts:
Can the evaluation of code snippets be undone in emacs? Or do I have to restart without having the code sitting in init.el to bring the system back to its previous state?

I tried out this code with M-x eval-region.

(define-minor-mode org-numbers-overlay-mode
  "Add overlays to org headings which number them"
  nil " *1." nil

  (let ((hooks '(after-save-hook
                 org-insert-heading-hook))
        (funcs '(org-promote
                 org-cycle-level
                 org-promote-subtree
                 org-demote
                 org-demote-subtree
                 org-move-subtree-up
                 org-move-subtree-down
                 org-move-item-down
                 org-move-item-up
                 org-move)))
      (if org-numbers-overlay-mode
       (progn
         (org-numbers-overlay-update)
         (dolist (fn funcs)
           (advice-add fn :after #'org-numbers-overlay-update))
         (dolist (hook hooks)
           (add-hook hook #'org-numbers-overlay-update)))

     (progn
       (dolist (fn funcs)
         (advice-add fn :after #'org-numbers-overlay-update))
       (dolist (hook hooks)
         (remove-hook hook #'org-numbers-overlay-update))

       (loop for o in (overlays-in (point-min) (point-max))
             if (eq (overlay-get o 'type) 'org-number)
             do (delete-overlay o))))))

(defun org-numbers-overlay-update (&rest args)
  (interactive)

  (when org-numbers-overlaymode
        (let ((levels (make-vector 10 0)))
          (save-excursion
            (widen)
            (goto-char (point-min))
            (while (outline-next-heading)
              (let* ((detail (org-heading-components))
                     (level (- (car detail) 1))
                     (lcounter (1+ (aref levels level)))
                     (o (or (loop for o in (overlays-in (point)
                                                        (save-excursion (end-of-line) (point)))
                                  if (eq (overlay-get o 'type) 'org-number)
                                  return o)
                            (make-overlay (point) (+ (point) (car detail))))))
                (aset levels level lcounter)
                (loop for i from (1+ level) to 9
                      do (aset levels i 0))
                (overlay-put o 'type 'org-number)
                (overlay-put o 'evaporate t)
                (overlay-put o 'after-string
                             (let (s)
                               (loop for i across levels
                                     until (zerop i)
                                     do (setf s (if s (format "%s.%d" s i)
                                                  (format " %d" i))
                                              ))
                               s))))))))

And it ended up breaking the TAB to fold headline function in org-mode. So I needed to undo the evaluation of the code. I did a restart to revert the changes, but having to restart every time a problematic code is evaluated seems to be quite a hassle.


texts:
I am trying the clear the inferior emacs lisp mode(ielm) buffer.
Solutions applicable to shell are not applicable here - the erase-buffer command says "Test is read only"


texts:
I want to slightly modify the behaviour of a function, old-function whose source I cannot modify.

I can do that simply by

(defun my-new-function (old-fn a b c)
  (if (evaluate-my-condition)
      (funcall old-fun (my-transform a) b c)
    (funcall old-fun a b c)))

 (advice-add #'old-function :around #'my-new-function)

This works well. However, I would rather have this functionality as a buffer-local minor-mode since I rarely need this modified functionality.

Since advice-add works globally (as is pointed out here), is there another way to achieve this?


texts: How can I make Emacs put files named like .#filename into another directory too

texts:
I want my autosave files and backup files, e.g. #filename.org# and filename.org~ files, not to clutter the directory in my code repo that is in TypeScript.
I have popped into a way to place inside another directory and it worked. However, after that I have seen another file popping up with .#filename.org.
What is this file for? How can I make Emacs put them into another directory too?


texts: How to change the indentation of major mode (SQL-mode)?

texts:
Configuration:

Emacs 25.0.50 on Ubuntu 15.04.

How to produce?

Do emacs -Q, then M-x sql-mode.

Paste the following in the buffer:

SELECT  SUM(T01.foobar)
FROM   db_foo.bar T01
WHERE   T01.fooID = 1
AND    T01.barID = 2
AND  T01.foo IS NOT NULL'

When I do C-x h, and then M-x indent-region, it says the
indent region is done. But the SQL statement is indented in an another way:

SELECT  SUM(T01.foobar)
FROM    db_foo.bar T01
WHERE   T01.fooID = 1
    AND T01.barID = 2
    AND T01.foo IS NOT NULL

I would like to change the indentation it in the following:

 SELECT  SUM(T01.foobar)
 FROM    db_foo.bar T01
 WHERE   T01.fooID = 1
 AND     T01.barID = 2
 AND     T01.foo IS NOT NULL

So I decided to change the indentation myself.
When looking on the source code of SQL mode,
I don't see any hints where I could change the indentation for words and for "AND".

Any suggestion how I could change the indentation of SQL string?


texts: Add original location of refiled entries to LOGBOOK after org-refile

texts:
With this setup (setq org-log-refile 'time) I have the following notes added to my TODO entry that I refiled (already twice and it is ended up in long someday-maybe):

* TASK Note on where the entry was refiled from
:LOGBOOK:
- Refiled on [2016-04-04 Mon 00:57]
- Refiled on [2015-05-15 Fri 13:53]
- State "TASK"       from ""           [2015-05-15 Fri 13:53]
:END:

What I would also like to have is the note about the place where it was refiled from. Like so:

* TASK Note on where the entry was refiled from
:LOGBOOK:
- Refiled on [2016-04-04 Mon 00:57] from ~/emacs-tasks.org::*Tasks%20workflow
- Refiled on [2015-05-15 Fri 13:53] from ~/stuff.org
- State "TASK"       from ""           [2015-05-15 Fri 13:53]
:END:

The problem is that the templates for adding notes org-log-note-headings do not support a proper placeholder (something like %F used in org-capture-templates). Moreover, it is explicitly not recommended to change these templates. Any suggestions how to achieve desired result?


texts: Working with SCHEDULED items (recurring task), org mode

texts:
When I schedule an item, I want to get something like:

** TODO Lift weights
   SCHEDULED: <2009-01-22 Thu +2d>
   - State "DONE"       [2009-01-16 Fri 23:14]
   - State "DONE"       [2009-01-14 Wed 17:25]

I suppose the state update for something like SCHEDULED: <2015-10-07 Tue>--<2015-10-17 Tue> would be the same.

The scheduling as such looks OK in the org-agenda (something like myfile: (1/11): TODO Lift weights.

However, how does the "- State "DONE" ..." part get inserted? What function or key-biding generate these lines (when the time comes)? How do I keep track of partial tasks?


texts: svg pictures from tikz in html export in windows

texts:
I want to create both PDF and HTML figures using Tikz for both purposes. I am doing as it is explained in here, answer of nberth.
To do this, I installed imagemagick for windows because this solution uses imagemagick's  convert tool. But I think Windows version of imagemagick does not include convert tool and even if it did, convert is a Windows file system utility. So I can't get SVG outputs working in Windows. Has anyone achieved this on Windows? What would you suggest.


texts: Multiuser wiki that I can edit/archive in Emacs Org-mode

texts:
If I could live entirely in Emacs, I would. But... I now have to collaborate with others on a shared wiki and my team requires a web interface to edit pages.

So I need to select a wiki engine. Ideally, while my team can update pages though the web, I would be able to do the same, entirely from within Emacs. The features I am looking for broadly include:

Open source and self-hosted
Git based wiki that I can checkout and archive locally, pulling changes and pushing updates as I go. Bonus points if it works with Magit
Access and edit via Emacs org-mode. If the entire wiki could live on my computer as a single org-mode document, that would be fantastic!
Easily install the wiki engine locally on my mac for config/testing and then easily porting this to the production server for deployment
Bootstrap themes available
Supported with a healthy developer community
Flat file architecture. I don't want to mess with databases

Any ideas?


texts: Shell mode: moving through the command history

texts:
In a shell in a terminal (Gnome Terminal + bash), the up and down keys allow me to browse through my command history.

In shell-mode inside emacs, the up and down keys move around the buffer, which is bit strange (but I admit can be useful in order to copy-paste parts of the buffer).

How can I browse the command history in shell-mode?


texts: Is there an org-babel for the Jython (not Python, it must be Jython) programming language? I am especially interested in session based evaluation for Jython. I am considering writing my own ob-jython.el, but want to make sure this has not been tackled yet.


texts:
I enabled company using the following commands in my init.el:

(require 'company)
(add-hook 'after-init-hook 'global-company-mode)

However I'm not getting filename completion, although there is some provider in the source and also the website mentions it's supported.

I start typing /home/emmanuel... and nothing happens, although I would expect the completion to start offering options?

Also, how does company-mode autodetect completion for relative paths, I think I read it's supported, but I'm not sure how it would detect it, without the initial "/" as a tip?


texts:
* one
* two
** books
*** IN-PROGRESS book1
*** book2
*** book3
* three
* four
** five
*** books
**** book4

How to get:

all headings title with todo-'IN-PROGRESS' keyword which are children of heading 'books'


texts: controlling display of latex equations in org-mode

texts: By default org-mode will overlap images of the latex equations for a given section, or for the whole document. If I press C-c C-c on an equation with an image overlay, all the images are removed. Can I make it so that only the one image is removed (and from which I can recreate the image by typing C-c C-x C-l?


texts:
In VC Directory Mode, how do I ignore multiple files?

My use case is that I have a LaTeX repository (in SVN, but that should not matter) with over 15 *.aux files in a subdirectory.

Attempt 1

Mark a couple of files in VC Directory Mode, then run C-x v G (vc-ignore).  The command still asks me for a file, so it does not use the marks.

Attempt 2

Run C-x v G (vc-ignore) and fill in a Wildcard, e.g., sections/*.aux.  This does not exclude any files from the VC Directory Mode buffer (refreshed with g), but it does add the wildcard to SVN.  I.e., when I do svn propedit svn:ignore . then a buffer opens with the sections/*.aux line in there.


texts: In evil-mode, how can I configure the seeking forward behaviour for all text objects?

texts:
I'm trying to understand the seeking behaviour in evil-mode. suppose you have this ([|] is point):

thi[s] is a text with a 'quote' -> command: ci'
this is a text with a '[|]'

Evil seeks forward to the nearest quote pair, erases what's inside the pair, moves point to there and places you in insert mode. Very powerful. Now, when you try to do that with round brackets:

thi[s] is a text with a (round bracket) -> command: ci(
thi[s] is a text with a (round bracket) -> nothing happens

in this case evil does not seek forward. seems that seeking forward only works with single and double quotes.

Why single and double quotes seek forward by default while the other text objects do not? How can I implement the seeking behaviour for evil text objects?


texts: Why do I get random white space in header_arg expansions when running shell scripts from Babel?

texts:
Please consider the following org-mode snippet containing code to call "show tables" on  a particular database via a sql code block and to dump out the database via mysqldump using an sh code block

*** Database
:PROPERTIES:
:header-args: :engine "mysql" :dbuser "user" :dbpassword "password" :dbhost "127.0.0.1" :database "mydb" :var dbuser="user" :var dbpassword="password" :var dbhost="127.0.0.1" :var database="mydb"
:END:

**** Test connectivity
#+begin_src sql
show tables;
#+end_src

#+RESULTS:

**** Dump schema
#+begin_src sh
echo mysqldump -u $dbuser -p $dbpassword -h $dbhost $database
#+end_src

#+RESULTS:
: mysqldump -u user^M^M -p password^M^M -h 127.0.0.1^M^M mydb

You will note that the line that is echoed contains spurious whitespace (line ends by the look of it).

Why is this and how can I make it go away?

If I remove the echo from the sh code block then I get the following error:

mysqldump: Got error: 2005: "Unknown MySQL server host '127.0.0.1^M^M' (8)" when trying to connect

So the whitespace is really there.  I am running GNU Emacs 25.0.94.2 (x86_64-w64-mingw32) of 2016-05-26 on Windows 10.  So it might be a Windows problem - haven't tried it on Linux yet, will do that when I get home from work.

For bonus marks, can someone tell me how to refactor the header_args so that I don't have to declare everything twice (once for SQL language specific headers and once for code block variables)?

Let me know what additional information I should provide as this is my first post.


texts:
How can I create an agenda view that filters items based on the property FOO?

TODO Test
:PROPERTIES:
:FOO:    <2018-11-09 Fri 12:43>
:END:

I would use org-agenda-skip-entry-if for this but the only templates I see are these:

scheduled     Check if there is a scheduled cookie
notscheduled  Check if there is no scheduled cookie
deadline      Check if there is a deadline
notdeadline   Check if there is no deadline
timestamp     Check if there is a timestamp (also deadline or scheduled)
nottimestamp  Check if there is no timestamp (also deadline or scheduled)
regexp        Check if regexp matches
notregexp     Check if regexp does not match.
todo          Check if TODO keyword matches
nottodo       Check if TODO keyword does not match

None of them seem to do what I want. Is there a way to write a custom predicate with access to the entry's properties?


texts: Emacs in PuTTY with xterm-mouse-mode: how to paste?

texts:
I'm running Emacs under PuTTY and this works better then I expected.
But since I sometimes use the mouse to focus the PuTTY window, I turned xterm-mouse-mode on. This way the focus in the text changes to where I click.

But now I can't past text into putty anymore.
Normally this is done by a right click and then putty sends the copied text.
But now Emacs receives a mouse-3 event first.

Is it possible to map mouse-3 to something so that the text after the mouse event is pasted to Emacs?

Here is my current config: https://github.com/r03/dotfiles/blob/master/.emacs.d/init.el


texts:
How to configure ace-window to put the active cursor always into minibuffer when pressing a special key (like i.e. 'z').

Reason is: I think it would be more convenient to always just press 'z' for switching to minibuffer.

ace-windows wiki mentions aw-dispatch-alist, but I'm unable to use it for this problem.


texts: Elisp to increase font-size in indirect buffer

texts:
I use org-mode for writing and frequently use a two pane setup, similar to the one described here: Org-mode 2-pane writing setup using indirect buffers (or display-buffer-alist. I have an outline on the left, and can open indirect buffers to work on particular subtrees. This function (which I bind to SHIFT-RETURN), opens up subtrees in a right hand pane, and then resize them, so I have a skinnier outline column on the left, and a writing window on the right.

    (defun org-tree-open-in-right-window ()
      (interactive)
      (org-tree-to-indirect-buffer)
      (windmove-right)
      (window-resize nil (- (truncate (* 0.7 (frame-width))) (window-width)) t)
    )

In addition to opening a subtree in an indirect buffer and changing the window size, I would like to set increase the font size of the right-hand window. That is the skinny, left-hand buffer would have a smaller font size, allowing a view on the whole document, while the right would be larger (in width) and larger in font-size, to facilitate writing.

I've tried: (set-face-attribute 'default nil :height 150) but this changes the font size in both. Is there a value I can pass, instead of nil, that would restrict this function to just a active window?


texts: Org-mode, collapse/expand section on click

texts:
Hi I'm on Linux and Emacs version is 26.3.

I would like to expand or collapse a block by mouse click, instead of moving the cursor to the header and press tab.

I actually have a windows computer does so, but do not work on my Linux one. I’ve tried to copy relevant files, however doesn’t work.

I also googled, but to be honest, cannot find where to start.

So if anyone can help? Thanks a lot!!


texts: Hightlighting all occurances of selected text

texts:
Within Visual Studio and Notepad++, when I select a symbol (using the shift key or mouse), other occurrences of it within the buffer are also highlighted in another color.

When editing JavaScript or AutoHotkey or any other dynamic language where you can use variables without defining them, it is very useful to be able to select some text and find all occurances of that string.

I am struggling particularly with Notepad++ and AutoHotkey, which highlights word matches, but I want to be able to select half of a symbol, for example within Suggest_ShowToolTip, I can even just select ToolTip and it should show the matches of ToolTip anywhere in the buffer, even if it part of a larger symbol.

Does such a feature exist?  Is it easy to implement?


texts:
I'm looking for ways to get the last copy from the kill ring in Emacs.

I run

(insert (yank))[cursor]

with C-x C-e and I get this *Backtrace*:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  insert(nil)
  eval((insert (yank)) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

What I'm trying to do is get the last copied text from the kill-ring (I think it would make it feel more polished if when I call this it removes the last copy from the kill-ring when ran, but I haven't found how to do that yet.), so I can have the defun that calls this get the last think I copied.

The command works correctly, but also calls up this Backtrace. I don't know what the backtrace message wants me to do? I would suspect that I'm not supposed to call yank in this manner.


texts: How to change Org-mode babel tangle write to file way as prepend instead of override by default?

texts:
There's an answer here for appending the current code block to an existing file.

I want to do the opposite, which is to prepend the current code block to an existing file. Could you please help?


texts: copy contents of current buffer in a temp buffer and operate on that

texts:
I need to copy the contents of the current buffer to a temp buffer, set that buffer to a particular major mode to take advantage of its benefits and get the information I need back to the main logic.

Is this complete madness? And if not, what's the structure for this?


texts: Binding key to save in specific directory?

texts:
I want to bind a key to save a timestamped backup of the current buffer to a specific directory. For example C-§ will save my current buffer to ~/Org/Backups/2017-01-01-foo.org.

Unfortunately every answer for something similar that I've seen looks unnecessary complicated and I would like to keep a simple binding for what should be a simple task.


texts:
I use text files for most of my work.
But for printing them on letterhead, I need to set margins to say 3 cm for upper margin and 2.5 cm for lower.
Is there any way I can define them in text-mode. Can I make them default for all my docs.
I don’t want to use LaTex or org-mode for simple few line letters or memos


texts: Cannot export org file into html. Error: make-htmlize-fstruct: Symbol’s function definition is void: record

texts:
For some reason I cannot export certain org-mode files to html. Org-files without headers work fine. However, if I have a file with

#+TITLE: This is the title of my website
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
#+OPTIONS: toc:t tex:t default TOC
#+STARTUP: inlineimages
This is my personal website.

I get the following error message make-htmlize-fstruct: Symbol’s function definition is void: record,
and this is the debugger result.

Debugger entered--Lisp error: (void-function record)
  record(htmlize-fstruct "#e1e1e0" "#2d3743" nil nil nil nil nil nil nil)
  make-htmlize-fstruct(:foreground "#e1e1e0" :background "#2d3743")
  htmlize-face-to-fstruct-1(default)
  htmlize-face-to-fstruct(default)
  htmlize-make-face-map((default underline font-lock-variable-name-face font-lock-string-face font-lock-type-face matlab-cellbreak-face font-lock-keyword-face font-lock-constant-face font-lock-comment-face))
  htmlize-buffer-1()
  htmlize-region(1 3566)
  org-html-htmlize-region-for-paste(1 3566)
  org-export-as(html nil nil nil (:output-file "index.html"))
  org-export-to-file(html "index.html" nil nil nil nil nil)
  org-html-export-to-html(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  call-interactively(org-export-dispatch nil nil)
  command-execute(org-export-dispatch)

Note that I had to remove some portion in the middle of the output, because it was very long and it had non-ASCII characters. I was able to found a similar issue here but don't know how they solved it. My emacs version is 25.2.2 and org-mode is v9.2. I am on a Linux Mint 19.1 machine.


texts: Set Consistent line spacing, irrespective of bold or underlines etc

texts:
I current have set the current line number face to be bold:

`(line-number-current-line ((,class (:foreground "#4F4F4F" :background "#00CC00" :bold t))))

When I move the cursor between lines, there is a very unpleasant movement of all the text, as the line with the bold text takes up a little more height, so that line gets taller, and then contracts when the cursor moves past it.

This is just a single example of where this issue is popping up. Another example is if any highlighting makes the word bold (e.g. matching parenthesis).

If I change the line spacing, there is just extra space between the lines, and bold text still expands even though there is adequate space.


texts: Ibuffer add an action to be executed on a group of buffers

texts:
So, below is what I have so far. It works to the extent of being able to delete single entry in the *Ibuffer* buffer. But, I would like it to work on all files marked with F. There's something I'm missing about this interaction, but couldn't figure out what it is:
(defvar ibuffer-force-deletion-char ?F
  "The character to display for buffers marked for force deletion.")

(defsubst ibuffer-force-deletion-marked-buffer-names ()
  (ibuffer-buffer-names-with-mark ibuffer-force-deletion-char))

(defsubst ibuffer-count-force-deletion-lines ()
  (ibuffer-map-lines-nomodify
   (lambda (_buf mark)
     (eq mark ibuffer-force-deletion-char))))

(defsubst ibuffer-map-force-deletion-lines (func)
  (ibuffer-map-on-mark ibuffer-force-deletion-char func))

(defun ibuffer-mark-for-force-delete (start end arg)
  "Mark for deletion the buffers in the region, or ARG buffers.
If point is on a group name, this function operates on that group."
  (interactive (ibuffer-get-region-and-prefix))
  (ibuffer-mark-region-or-n-with-char start end arg ibuffer-force-deletion-char))

(define-ibuffer-op ibuffer-do-force-kill-on-deletion-marks ()
  "Kill buffers marked for deletion as with `kill-this-buffer'."
  (:opstring "force-killed"
             :active-opstring "force-kill"
             :dangerous t
             :complex t
             :mark :force-deletion
             :modifier-p t)
  (with-current-buffer buf
    (let (kill-buffer-hook kill-buffer-query-functions)
      (if (kill-buffer buf)
          'force-kill
        nil))))

(define-key ibuffer-mode-map (kbd "C-c x") 'ibuffer-do-force-kill-on-deletion-marks)
(define-key ibuffer-mode-map (kbd "f") 'ibuffer-mark-for-force-delete)


texts: In org-mode, can I include a horizontal separator in a result table generated by an Emacs Lisp code block?

texts:
I have some Emacs Lisp code blocks in an Org file which I evaluate to get tables of results.  It would be nice if I could include horizontal separators to separate individual lines of data from headers and summary lines, because that makes it easier to use org-sort.  Concretely, I have something like this:

#+BEGIN_SRC emacs-lisp
'((foo bar baz) (1 2 3) (4 5 6))
#+END_SRC

#+RESULTS:
| foo | bar | baz |
|   1 |   2 |   3 |
|   4 |   5 |   6 |

but it would be nice if I could make the output automatically format itself more like this:

#+RESULTS:
| foo | bar | baz |
|-----+-----+-----|
|   1 |   2 |   3 |
|   4 |   5 |   6 |

Is there an easy way to do this?  I thought that including nil in place of a row of results might do the trick, but it seems not to do the trick.


texts:
disclaimer: I'm still relatively new to Emacs.

When I open an Epub on MS Windows, Emacs opens it using Zip-Archive mode and displays its content (which is normal afaik).

However, when I start nov-mode, encoded characters are displayed and I got an error of Wrong type argument: stringp, nil in the minibuffer.

What should I do? Where should I look?

EDIT
You can find sources of nov here


texts: Restrict agenda to current buffer (with few keystrokes)

texts:
I would like to call an agenda which is restricted to the current buffer, even if it is not in the agenda files.
I tried to go one way with a custom agenda here, but it feels like maybe peeling the banana from the wrong side.
I know about the < feature in the agenda dispatcher, but maybe there is a shorter way.
How can I call an agenda, which is restricted to the current buffer, using as few keystrokes as possible?


texts: How to initialize org agenda on Emacs startup?

texts:
I have a quite extensive org-agenda-files, so the first time I load an agenda view after starting the Emacs process, I have to wait ~20sec.  I'm using Emacs in daemon mode (via systemd user service).

How can I have Emacs initialize the org-agenda on daemon startup, so that once I'm in Emacs, I don't have to wait when displaying an agenda for the first time?


texts: Auctex not displaying pdf correctly using pdftools

texts:
I am using pdftools with AUCTEX so that I can display output within emacs. I am using a windows system with emacs 25.3. However after compilation I get the following:

%PDF-1.5
%
3 0 obj
<<
/Length 2521
/Filter /FlateDecode
>>
stream
xڭYY 7~ _!`_Z      }k{ q6# 8g k {҇' ۷ E !5 y & W     n  {-ŪH Ld     :  * * ,_  W       *L   ǟ     " > ӏ ֟o }   U 9   F   )RcL b-Y q   ͛? 7R    +j< ~kQ$ 7   t   3X )g  HMg    <  N   "š C    )  FC]Mߺk  k  M ؔ d

Also when I start emacs I get the following message:

need to build the epdfinfo program. do it now?(y or n)

If I answer yes then it asks me the following:

Do you have Msys2 installed?

It then asks the directory into which this is installed. Not sure what this is or where its installed.

In my unit file I have the following lines:

;;latex extra package - additional goodies.
(add-hook 'LaTeX-mode-hook #'latex-extra-mode)
(setq latex-run-command "pdflatex")

;;use pdftools to preview
(pdf-tools-install) ;; start server

 (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
 TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
    TeX-source-correlate-start-server t) ;; not sure if last line is neccessary

;; to have the buffer refresh after compilation
 (add-hook 'TeX-after-compilation-finished-functions
        #'TeX-revert-document-buffer)

Any help appreciated.


texts: "C-c C-v" for "View TODO items in a sparse tree" not working

texts: I'm using Emacs (v 24.5.1) on Windows 7. I have a .org file containing some todos. I read here and in various tutorials that C-c C-v is for "View TODO items in a sparse tree" (for the current buffer). But for me it does nothing, it only waits for another argument to be provided. How can I get this to work?


texts:
I have which-function-mode enabled and from time to time it shows ???. Is it possible to customize this to eg '∅'. I have tried to customize group "Which Func" but did not find something suiteable.

Also I do not completely understand when ??? is shown and what is means.


texts: how to disable vertical auto-centering of cursor

texts: I recently had my Ubuntu Linux upgraded to 14.04, and my emacs got upgraded to 24.3.1 in the process. I noticed that it scrolls by itself. I finally realized that it automatically centers the cursor vertically after a few seconds. This is extremely annoying to me. I decided to give it a try for an hour or so to see if I can get used to it, but it still annoys me. I went to the options menu, but I see nothing about that feature. Can anyone tell me how to disable it? Thanks.


texts:
I use doom emacs. Starting emacs normally works just fine.
Having an emacs daemon and trying to use emacsclient -c causes the following error:
*ERROR*: Symbol’s function definition is void: persp-mode-start-and-remove-from-make-frame-hook

I am using emacs 27.1


texts: How can I convert a C-key code into a 'normal' key code?

texts:
Background

With jumping packages like Ace and Avy, you can start a function, provide a query char, and then jump to somewhere based on further input. (Lately I've preferred Avy, but that's irrelevant here.)

I have had both bound to C-' C-; (with other jumping functions bound to the home row) so that I can just hold control and fire off the sequence. It's very distracting though to have to lift my finger off control to input a 'plain' character for read-char to read.

Question

How can I strip all modifier keys off a read-char-returned key code?


texts: How to make email in emacs work with an Oauth2 requirement?

texts: I have been using gnus for my various email accounts for years, but now my university has moved to outlook.office365 which requires oauth2. I can see that there is an oauth2 package for emacs, but no examples on its use nor how one might combine with gnus. And while I can see some online examples of people using offlineimap oauth2 with gmail I have not seen it for MS o365. Apparently Thunderbird can use oauth2. Has anyone had success with any of the emacs email applications (but gnus preferred)? If so, can you give some suggestions please? If not, any ideas how to figure out what Thunderbird is doing so that it might be emulated in gnus. Even a simple walkthrough the oauth2 package would be helpful.


texts: How can I unhighlight everything highlighted by `highlight-regexp`?

texts:
If I do this:

M-x highlight-regexp \cite{\(.+\)}

then pick a color. Later, if want to unhiglight all previous higlights, I have to do them one by one, e.g.

M-x unhighlight-regexp \cite{\(.+\)}

Is there not a command to un-highlight all?


texts: Cargo-process does not accept user input

texts:
Using the Emacs mode for Cargo, I'm able to build and run Rust code inside Emacs. However, the terminal that opens when executing cargo-process-run does not accept user input.

For example, when running

use std::io;
fn main() {
  let mut input = String::new();

  io::stdin()
      .read_line(&mut input)
      .expect("Failed to read line.");
}

the terminal will hang without being capable of receiving keyboard input.

I've read that a similar problem can occur when executing compile, but this could somehow be resolved by starting in comint-mode. Unfortunately, I have not found a way to translate that solution to this scenario.

How can I resolve this?


texts: Has matches , but re-builder print "No matches"

texts:
Emacs 26.1

In scratch buffer I has text

KRW-EOS
hel-how
hello-how-ar
h-privet
kak-del
123-567
aaa-bbb
AAA-BBB
AAAA-BBBB
AAA-BB
AA-BBB
A-A
AAAAAAAAAA BBBBBB
AAA BBB
ZZZ-YYY

M-x regexp-builder

Input next regexp:

\b[A-Z]{3}-\b[A-Z]{3}

But I get message: No matches

Why?

KRW-EOS - is match!!!


texts: Is it possible to place TODO keywords at end of heading

texts:
I want to have an org file like this example :

#+OPTIONS:
#+TYP_DODO: KO | OK
#+TODO: KO | OK

* Automated tests results [62%] / [5/8]
:PROPERTIES:
:COOKIE_DATA: recursive
:END:
** results group 1 [50%]
*** test 1 : OK
*** test 2 : KO
*** test 3 : OK
*** test 4 : KO
** results group 2 [75%]
*** test 1 : KO
*** test 2 : OK
*** test 3 : OK
*** test 4 : OK

To achieve this I need to have the TODO keyword at the end of the heading line instead of at the beginning.
Is it possible? If so how?


texts:
I'm looking to create a command which stores a kind of "history" for the current major-mode. I need the variable to be independent for each major mode, but consistent across all buffers in any particular major mode. For example, all buffers in python-mode should use the same version of the variable and all buffers in emacs-lisp-mode should use a single, different version of the variable.

Emacs has the ability to have buffer-local variables. Is there a way to make a variable that is mode-local?


texts: How to make shell-command run using shell profile and current directory hooks (ex. direnv)

texts:
I am trying to get shell-command and async-shell-command to integrate seamlessly with a couple of programs in my .bashrc file, specifically direnv in this example.

I found that if I customized shell-command-switch, I could get shell processes to load my profile as if it were a regular interactive login shell:

(setq shell-command-switch (purecopy "-ic"))
(setq explicit-bash-args '("-ic" "export EMACS=; stty echo; bash"))

I am also using exec-path-from-shell.

Say I have a ~/.bashrc file with:

...

eval "$(direnv hook $0)"
echo "foo"

Inside ~/code/foo I have a .envrc file with:

export PATH=$PWD/bin:$PATH
echo "bar"

If I run M-x shell with default-directory set to ~/code/foo, a bash shell will correctly load my profile and run the direnv hook to add that to my path:

direnv: loading .envrc
bar
direnv: export ~PATH
~/code/foo $ echo $PATH
/Users/username/code/foo/bin:/usr/local/bin:... # rest of $PATH

However if default-directory is still ~/code/foo and I run M-! echo $PATH, it correctly loads my .bashrc but doesn't execute the direnv hook of the current directory:

foo
/usr/local/bin:... # rest of $PATH without ./bin

I get the same result if I run M-! cd ~/code/foo && echo $PATH.

Is there a way I can advise or hook into shell-command or start-process to make it behave as if it were being sent from an interactive shell buffer?


texts: Avoiding typographic "rivers" with Emacs

texts:
When reading manuals in *info* mode, I found rivers somewhat distracting. For example, the left image is what I see on the screen, whereas the right one have some rivers annotated out. (see also Tex.SE, and DSP.SE)

Is there anyway to avoid them? I have did a lot of searching, but haven't found a relevant package yet. The Emacs community doesn't seem to care too much about this issue...


texts:
I'm looking for a way to display hidden characters like newline and tab characters in emacs. I am NOT trying to convert the characters, just display them in the current buffer.

In vi(m), I can do this with the :set list command. Additionally, I can customize the appearance of the characters something like this:

set listchars=tab:▸\ ,eol:¬

This makes it easy to see tabs and where new lines start. I desperately need this feature in emacs as well, can someone provide it?
Many thanks.


texts: How to run a keyboard macro (saved in my init.el) automatically when Emacs starts up?

texts:
I have saved a keyboard macro in my init.el file as follows
(fset 'remember-notes-my-macro
   (lambda (&optional arg)
     "Keyboard macro."
     (interactive "p")
     (kmacro-exec-ring-item
       (quote ([134217848 114 101 109 101 109 98 101 114 45
                110 111 116 101 115 return 134217848 114 101
                99 111 118 101 114 45 116 104 105 115 45 102
                105 108 101 return 121 101 115 return] 0 "%d"))
     arg)))

I want to run this macro automatically when Emacs starts up. I tried to add the line (remember-notes-my-macro) in my init.el to run it when Emacs is launched, but I got a fatal error at startup.

I have never debugged Emacs, so I don't know what to do about it. The macro runs fine with M-x remember-notes-my-macro when Emacs is already running.
How can I get the macro to run automatically at startup?
Note: What this macro does is, it runs remember-notes to open notes. Then it runs recover-this-file to recover autosave data and then it enters yes at the minibuffer prompt.


texts: How to change lisp mode indentation style

texts:
I'm not a lisp programmer. But I'm an emacs user, so I use elisp from times to times to do simple scripting. I'm not familiar with lisp style and I'm quite incompatible with it. Default indents quickly become over 80 whitespaces long making the program unreadable. Lisp style implies writing all braces in the single line and that makes me crazy. I'm much more comfortable with the K-R notation:

def doSomething() {
  ...
}

That style may be easily adopted to lisp code:

(defun doSomething ()
   ...
)

So I'm using it for my code, see example. But accidental calls to the indent function ruins line. That is not a big deal, undo function works well. But that still bothers me.

So I'd like to change indent function for lisp mode in either way:

work like for java mode (preferred)
do nothing (not make things worse at least)


texts: notmuch-mode very slow in emacs-mac-port (railwaycat)

texts:
I run Emacs on Mac OSX, I'm trying to switch from Emacs for Mac OSX to Emacs Mac Port.

I use notmuch for email. It works perfectly on Emacs for Mac OSX.

But on Emacs Mac Port, it's prohibitively slow. Also, the message list is messed up, double spaced and with strange boxes:

I'm using the exact same configuration as I do with Emacs for Mac OSX.

What's causing these problems, and how do I fix them?


texts: Emacs-ESS not closing curly braces within .R files

texts:
in my .emacs file I have:

;; enable skeleton-pair insert globally
(setq skeleton-pair t)
;;(setq skeleton-pair-on-word t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\`") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "<") 'skeleton-pair-insert-maybe)

extracted directly from here ESS autocomplete. Everything related to ESS is:

;;=============================
;;R
;;==============================
;;Enable R
(add-to-list 'load-path "~/ess-15.03-1/lisp/")
(load "ess-site")
(setq ess-eval-visibly 'nil)
(setq ess-ask-for-ess-directory 'nil)
(add-hook 'ess-R-post-run-hook 'ess-execute-screen-options)
(define-key inferior-ess-mode-map "\C-cw" 'ess-execute-screen-options)

(eval-after-load "comint"
  '(progn
     (define-key comint-mode-map [up]
       'comint-previous-matching-input-from-input)
     (define-key comint-mode-map [down]
       'comint-next-matching-input-from-input)
     ;; also recommended for ESS use --
     (setq comint-scroll-to-bottom-on-output 'others)
     (setq comint-scroll-show-maximum-output t)
     ;; somewhat extreme, almost disabling writing in *R*, *shell* buffers above promp
     (setq comint-scroll-to-bottom-on-input 'this)))

Auto-completion of the braces (or auto-closing them) will work with everything: .py files, .txt files, even when I am in the R console launched with ESS (M-x R). However, it will not complete the curly braces when the file is and R file (e.g. foo.R). All other skeleton-pair options work everywhere, the only one that does not is the curly braces.

I read here that some other people has problems with curly braces related with the definition of the ess-electric-brace at ess-mode.el. However, their problems are different than mine. It seems that they cannot close the braces. In my case, is simply that it will not auto-complete them, so I am not sure the solution will be the same.

I see that in ess-mode.el there is a line:

(define-key map "{"          'ess-electric-brace)

and there is not such a thing for ( or [ so I guess is related to that, but do not know how to change it.

Any suggestions?


texts: Ensuring a minimum version with use-package

texts: In my .emacs, I would like to ensure that the s package, version 1.10.0 or newer, is installed. If I use (use-package s :ensure t) it will not upgrade the installation on systems with older versions of s. How do I ensure that the minimum version is present?


texts:
I would like to set a projectile find file function to the hotkey C-e, and a elpy-goto-definition function to the hotkey F12, but I'm not sure why spacemacs is not recognizing the config that I'm trying to set. Here's my config:

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  (global-set-key "f12" 'elpy-goto-definition)
  (global-set-key (kbd "C-e") 'projectile-find-file))

I've tried various combinations of these. I've read that global keys have low priority, maybe this is why, but I feel a leader key is not the correct option.


texts: Get list of active minor modes in buffer

texts:
How get a list of active minor modes in current buffer?
Docs (info "(elisp)Minor Mode Conventions") say:
 Define a variable whose name ends in ‘-mode’.  We call this the
 "mode variable".  The minor mode command should set this variable.
 The value will be ‘nil’ if the mode is disabled, and non-‘nil’ if
 the mode is enabled.  The variable should be buffer-local if the
 minor mode is buffer-local.

I ended with:
(dolist (m minor-mode-list)
  (when (symbol-value m)
    (push m modes)))

describe-mode sources have notes that:
;; Older packages do not register in minor-mode-list but only in
;; minor-mode-alist.

I don't know if that still valid point...


texts: I wrote an interpreter by leveraging --batch, read-from-minibuffer and princ.  Now, reading input is relatively limited, you can type consecutive characters, erase the last character with <backspace>, send a line with RET and cancel input with C-d (or C-c, but that aborts the entire program).  This is good enough for testing, but I'd like to shoot for more readline-like editing.  Is it possible to intercept individual control keys before printing them and how?


texts:
I'd like to paste images from the system clipboard into an Org file. Emacs should write the clipboard content to a suitable file (likely an attachment) and insert a suitable link (see https://orgmode.org/manual/Images.htm) to it at point.
Has this been implemented yet anywhere?


texts: How can I get a plain string with the clocked time and the estimate effort for the current task clocked-in?

texts:
I'm drowning in parenthesis here. I want to write a function which returns in a string the time and the effort estimate of the current clocked task.

I first looked in org-mode checking I wasn't re-doing the wheel, I found org-clock-get-clock-string which does what I want but it appends things I don't need making the string unusable for what I want. I took a look at the source code and tried to adapt it to do what I want, however, I fail miserably, I did this mess:

(defun shackra/task-clocked-time ()
  "Return a string with the clocked time and effort, if any"
  (let* ((clocked-time (org-clock-get-clocked-time))
         (h (floor clocked-time 60))
         (m (- clocked-time (* 60 h))))
    (if org-clock-effort
        (let* ((effort-in-minutes
                (org-duration-string-to-minutes org-clock-effort))
               (effort-h (floor effort-in-minutes 60))
               (effort-m (- effort-in-minutes (* effort-h 60)))
               (work-done-str (format org-time-clocksum-format h m))
               (effort-str (format org-time-clocksum-format effort-h effort-m))
               (clockstr (concat  " [%s/" effort-str
                                  "] (" (replace-regexp-in-string "%" "%%" org-clock-heading) ")"))))
      (format clockstr work-done-str))
    (format
     (concat "[" org-time-clocksum-format " (%s)]")
     h m org-clock-heading)))

but executing the function for testing yells this error:

Debugger entered--Lisp error: (wrong-type-argument stringp (:days "%dd " :hours "%d" :require-hours t :minutes ":%02d" :require-minutes t))
  format((:days "%dd " :hours "%d" :require-hours t :minutes ":%02d" :require-minutes t) 0 12)
  (let* ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) (effort-h (floor effort-in-minutes 60)) (effort-m (- effort-in-minutes (* effort-h 60)))) (format org-time-clocksum-format h m))
  (if org-clock-effort (let* ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) (effort-h (floor effort-in-minutes 60)) (effort-m (- effort-in-minutes (* effort-h 60)))) (format org-time-clocksum-format h m)))
  (let* ((clocked-time (org-clock-get-clocked-time)) (h (floor clocked-time 60)) (m (- clocked-time (* 60 h)))) (if org-clock-effort (let* ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) (effort-h (floor effort-in-minutes 60)) (effort-m (- effort-in-minutes (* effort-h 60)))) (format org-time-clocksum-format h m))))
  shackra/task-clocked-time()
  eval((shackra/task-clocked-time) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

To be honest, I don't know what I'm doing and I neither know how to read the code of org-clock-get-clock-string (the lacks of documentation in that code kills me)


texts: Flycheck variable warnings despite flycheck load-path

texts:
I'm trying to get Flycheck to load files containing declarations to resolve warnings to free variables etc. But Flycheck is not picking up the (required files. I use (require 'my-dcls) at the top of code files, and (provide 'my-dcls) at the bottom of my declarations file.

I'm running Emacs 24.4 as an app on OSX, and using Flycheck 20160622. I've updated all my packages to the latest available versions using ESC-x list-packages, U.

So far I have learned that:

Flycheck doesn't use the Emacs load-path, by default policy.
(setq-default flycheck-emacs-lisp-load-path 'inherit) in the Emacs init file should tell Flycheck to use the Emacs load-path.
All Flycheck variables are buffer local, so (setq flycheck-emacs-lisp-load-path ..) won't work globally.
You can (setq-default flycheck-emacs-lisp-load-path (list "dir1" "dir2")) to create a specific load path to your custom files.

So, following all those guidelines,

I tried (setq-default flycheck-emacs-lisp-load-path 'inherit) on line 1 of my init file, but without success. I can see the inherit value in every code buffer that I visit when I evaluate flycheck-emacs-lisp-load-path in the minibuffer.
I tried (setq-default flycheck-emacs-lisp-load-path (list "dir1" "dir2")) on line 1 of my init file, but without success. I can see the ("dir1" "dir2") value in every code buffer that I visit when I evaluate flycheck-emacs-lisp-load-path in the minibuffer.
In both of those cases, (member 'my-dcls features) shows that my declarations file feature has been loaded, which means that Emacs (not necessarily Flycheck) has found and loaded the files successfully (so they do exist).

And still, Flycheck prints out free variable warnings to variables that are defined in my declarations file with (defvar my-variable) statements. If I kill and yank those same defvar statements from the declarations file into the current code buffer, Flycheck stops complaining.

I'm really at a loss to know what to do next. Everything seems in order, but the results say otherwise.

See also this related post here, which is a near duplicate (except that the suggested answers don't work for me on my machine configuration).

Here is my entire .emacs init file, to make sure that nothing else interferes with Flycheck.

(setq-default flycheck-emacs-lisp-load-path
              (list "/Users/me/Dropbox/emacs/"))

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
  (package-initialize)

  (use-package flycheck
    :ensure t
    :defer t))

(require 'flycheck)

After starting Emacs, I read in a Lisp source file that contains (require 'my-dcls), where my-dcls.el resides in the directory named in the flycheck-emacs-lisp-load-path variable, /Users/me/Dropbox/emacs/.

In the source file buffer, I can eval flycheck-emacs-lisp-load-path, and can see the directory I loaded in there. Any ideas for further debugging to get Flycheck to pick up the load path are welcome.

I had a look at the flycheck source, but it seemed beyond me for effective debugging (not sure I have the skills for that yet). Thanks.


texts:
It seems that helm prefers shorter paths when ordering the current set of matches. Is there a way to keep this general behavior but also take the number of matches into account?

In the screenshot I am searching for generator block and would prefer to have client/src/app/shared/block/generator/generator.ts as first hit because it contains two occurences of generator.


texts: Publish org-mode to HTML using a separate directory for each post

texts:
I want to publish each of my org-mode posts so the HTML output uses a separate folder for each post.  I want to avoid .html in the URL.  I want the posts to look like http://example.com/my-org-post/ instead of http://example.com/my-org-post.html.

Is there a publishing setting to achieve this?


texts: Completion by fuzzy search in large dictionary file, displaying candidates inline

texts:
What would be the best (simplest, with minimal latency) way to load a large dictionary file (about 2M terms; plain text, one term per line), and then do (repeatedly, on a keystroke) a fuzzy search, with the candidates displayed inline?

The search can be started after the fist search token has been typed (like with completion-at-point-functions) or ab initio.

Something like fzf or ivy? But I cannot figure out how to read plain text from a particular file and keep it in memory.

Clarification: there is a ton of packages doing various flavors of completion and presenting the results in the minibuffer (and some also open an annoying helper window at the top of the frame). Those are not the droids I am looking for. I would like to see my completion candidates inline (at point): a dynamic list being displayed immediately under the query as it is typed.


texts: Exporting a bullet point in org-mode to theorem/defintion in latex

texts:
I'm two weeks old in Emacs and just short of one in org-mode, so not that much knowledge. I want to use org-mode to take my university and research notes. Some of those, are needed to be exported as LaTeX, say for an annual report. I know I can use

#+begin_definition
The Price of the Anarchy is defined as...
#+end_definition

to create a latex

\begin{definition}
The Price of the Anarchy is defined as...
\end{definition}

Cool. But this does not look good in org-mode. What I would love to do is something like this:

** Price of Anarchy                         :definition:
    The Price of the Anarchy is defined as...

And it would generate something close to the other case.

The same could be said about other environments, like proof, theorem, those more commonly used in maths and CS.

So, to sum it up: is there a way to place a tag like ":definition:" and transform the bullet point into that environment? And if not, can someone point how to make a script/hook (not sure what to call, again, emacs noob here) on how to do something like this?


texts: What is the point of the Ctrl-M binding? Can I overwrite it if I use the Return key?

texts:
Looking for a new convenient keybinding for a frequently used command I stumbled upon Ctrl-M which is the same as Return/Enter.

What is the point of this binding? Can it cause some problem if I overwrite it?


texts: Customizing c-mode indentation behavior in Emacs 24.4

texts:
Before Emacs 24.4, indentation in c-mode happened after typing things like ;, , and so on and I like this behavior.

But in Emacs 24.4, c-mode also indents on RET. This causes a lot of problems for me because if I want to insert a blank line, I need to press RET and then delete any spaces or tabs that electric- inserts.

So I would like to disable indent on RET, but keep all other electric-indent functionality, like indent on ;.

How can I achieve this?

I tried calling (electric-indent-local-mode -1) in c-mode hooks,
but this disabled not only indent on RET, but also indent on ;, , and so on.


texts:
I have this code that used to work fine until today:

(let* ((newest-pkg (cadr (assq 'org package-archive-contents)))
       (installed-pkg (cadr (or (assq 'org package-alist)
                               (assq 'org package--builtins)))))
  (when (version-list-<= (package-desc-version newest-pkg) (package-desc-version installed-pkg))
    ;; Instalamos la nueva versión de org-mode
    ;;(package-install newest-pkg)
    (message (format "Paquete «%s» actualizado de la versión %s a la versión %s"
                     (package-desc-name newest-pkg)
                     (car (package-desc-version newest-pkg))
                     (car (package-desc-version installed-pkg))))
    ;;(delete-directory (package-desc-dir installed-pkg) t)
    ))

However, it is failing with this error:

Debugger entered--Lisp error: (wrong-type-argument listp [nil nil "Outline-based notes management and organizer"])
  cadr((org . [nil nil "Outline-based notes management and organizer"]))
  (let* ((newest-pkg (cadr (assq (quote org) package-archive-contents))) (installed-pkg (cadr (or (assq (quote org) package-alist) (assq (quote org) package--builtins))))) (if (version-list-<= (progn (or (and (memq (aref newest-pkg 0) cl-struct-package-desc-tags)) (error "%s accessing a non-%s" (quote package-desc-version) (quote package-desc))) (aref newest-pkg 2)) (progn (or (and (memq (aref installed-pkg 0) cl-struct-package-desc-tags)) (error "%s accessing a non-%s" (quote package-desc-version) (quote package-desc))) (aref installed-pkg 2))) (progn (message (format "Paquete «%s» actualizado de la versión %s a la versión %s" (progn (or (and ...) (error "%s accessing a non-%s" ... ...)) (aref newest-pkg 1)) (car (progn (or ... ...) (aref newest-pkg 2))) (car (progn (or ... ...) (aref installed-pkg 2))))))))
  eval((let* ((newest-pkg (cadr (assq (quote org) package-archive-contents))) (installed-pkg (cadr (or (assq (quote org) package-alist) (assq (quote org) package--builtins))))) (if (version-list-<= (progn (or (and (memq (aref newest-pkg 0) cl-struct-package-desc-tags)) (error "%s accessing a non-%s" (quote package-desc-version) (quote package-desc))) (aref newest-pkg 2)) (progn (or (and (memq (aref installed-pkg 0) cl-struct-package-desc-tags)) (error "%s accessing a non-%s" (quote package-desc-version) (quote package-desc))) (aref installed-pkg 2))) (progn (message (format "Paquete «%s» actualizado de la versión %s a la versión %s" (progn (or (and ...) (error "%s accessing a non-%s" ... ...)) (aref newest-pkg 1)) (car (progn (or ... ...) (aref newest-pkg 2))) (car (progn (or ... ...) (aref installed-pkg 2)))))))) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

What am I doing wrong?

EDIT: This is how I'm setting the package archive.

(setf package-enable-at-startup nil)
(package-initialize)
(setf package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("org" . "http://orgmode.org/elpa/")
                         ("gnu" . "https://elpa.gnu.org/packages/")))

(unless package-archive-contents
  (package-refresh-contents))

My Emacs version is GNU Emacs 24.5.1 (i686-pc-linux-gnu, GTK+ Version 3.20.6) of 2016-06-04 on juergen.


texts: Emacs lisp throwing error when using spell check

texts:
I am trying to configure Hunspell in my emacs running in windows. When I type M-x ispell-buffer, I get the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("," nil 0)
  split-string(nil "," t)
  ispell-parse-hunspell-affix-file(nil)
  ispell-find-hunspell-dictionaries()
  ispell-set-spellchecker-params()
  ispell-region(1 25)
  ispell-buffer()
  funcall-interactively(ispell-buffer)
  call-interactively(ispell-buffer record nil)
  command-execute(ispell-buffer record)
  execute-extended-command(nil "ispell-buffer" "ispell-bu")
  funcall-interactively(execute-extended-command nil "ispell-buffer" "ispell-bu")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

My .emacs file looks like this:

(setq exec-path (append exec-path '("D:/programs/emacs/hunspell/bin/")))

(setq ispell-program-name "hunspell")
;; below two lines reset the the hunspell to it STOPS querying locale!
(setq ispell-local-dictionary "en_US")
;; "en_US" is key to lookup in `ispell-local-dictionary-alist`
(setq ispell-local-dictionary-alist
      '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']"
     nil ("-d" "en_US") nil utf-8)))


texts: How can I invoke Flutter "Context commands" interactively (from lsp-dart)

texts:
I was beyond stoked to discover how complete Flutter support is in Emacs these days thanks to the seemingly polished lsp-dart (featured prominently in the official "get started" docs for Flutter, awesome).
Anyways, when I hover over a Flutter widget while lsp-ui is enabled I get this nice yellow list of "Context Actions" hovering off to the right that I can click on to perform the action, just like in Android Studio. I'm trying to figure out how to use those without touching my mouse, but I can't for the life of me figure out what commands they're actually running. I've grepped around my entire elpa directory to no avail. (Yes the time I've spent researching this question has probably already outweighed the time I'll save by not having to touch my mouse, but it's really about comfort and joy, isn't it?)
Are these interactive commands that I can run? Alternatively, does anyone know how this hovering list is built in lsp-ui? Might help with the source dive.


texts:
I can recover a file from an auto-save via M-x recover-this-file. So far so good.
But how can I recover a file from it's last backup (if, of course, I have switched backups on)?


texts: Replacing string in a region and conditional replace

texts:
My goal is to write a simple function that can do the following:

Staring with an expression that looks like

$$ x = y $$
$$ y = z $$
$$ z = x $$

(There can more lines of such equations)

I want to write a elisp function that when I run it after selecting this region, I get the following

\begin{align}
x = y \\
y = z \\
z = x
\end{align}

I need to do a conditional replace on $$ depending on whether it is near the beginning of the line or the end of the line. Moreover, I also need to do not replace the last $$ with \\ but with \end{align}. I am new to elisp and I could not figure out how to do a conditional replace and also how to restrict the replace to the region I selected.

Any help is greatly appreciated.


texts: How to open files in eshell with wildcards

texts:
I am very used to typing in a shell something like:

emacsclient **/Threshold.java

Where Threshold.java is a file deeply nested in a directory and I just want to
open it by name.

When I try the same thing in eshell, I get (ec is an alias for find-file):

ec **/Threshold.java
Wrong type argument: stringp, ("src/main/java/org/elasticsearch/shield/admin/Threshold.java")

How can I get this working in eshell?


texts: Always remove brackets by pairs - fix hungry-delete-mode and smartparens-strict-mode conflict

texts:
Enabling smartparens-strict-mode breaks hungry-delete-mode as it overrides the hungry-delete remaps for C-d and C-h with smartparens specific functions. Hence, I have disabled smartparens-strict-mode but I want to have the ability to always delete by pairs. I do not want to use electric-pair-mode since it overrides some of the functionality of smartparens.

How can I achieve this while also preserving hungry-delete-mode functionality?

Thanks


texts: Generate a TOC (index.org) file out our headings from all org files

texts:
Currently i have around 25 org files each with multiple headings. Everytime i want to go over my notes, i need to remember the name of the file and open it (faster if its in buffer, else i need to go to the org folder)

Is there a way to generate a TOC of files/heading1 for all files under the org-directory and place it under an index.org?

P.S: Google did not return any good package!


texts: How to mapping from the value of one alist entry to the value of another entry of the same alist

texts:
I have a data structure like:
((fid . FID) (name . NAME) (count . COUNT) (data . ORIGINAL_DATA))

I have following Elisp code try to interactively select FID through display
the NAME instead of FID.

(defun emms-bilibili-favlist-select ()
  "Interactive select which favlist to open."
  (let* ((fav-name (completing-read "Select favlist: "
                                    (mapcar
                                     (lambda (x) (alist-get 'name x))
                                     (emms-bilibili--retrieve-favfolder))))
         ;; TODO:
         (favlist ...)
         )
    (emms-bilibili--retrieve-favlist (alist-get 'fid favlist))))

I need it to display a list in interactive select:

NAME A
NAME B
NAME C

When I select "NAME A", code need to get the corresponding FID. (upper code is
just my pseudo code, if you have better solution, please tell me, Thanks.)


texts: When interacting with postgresql via Emacs sql-postgres, is it possible to write aliases or functions, to be able to type for example, databases instead of \l, when I want to list all databases?


texts: I have installed the Rust programming language (Debian). Now i can compile and run programs from terminal (with the cargo build and cargo run commands), but not from inside emacs. The cargo compiler stays on my system in /home/me/.cargo/bin/cargo and emacs is not looking there to find the interpreter. I get this error /bin/bash: cargo: command not found by running M-x &, cargo build. So how can i tell emacs the address of cargo binary, or is it better to send the binary to the address emacs looks in?


texts: How to generate and activate autoloads for local packages?

texts:
It is clear that not all local/custom/personal packages should be officially released, and it would be silly to do so just to benefit from built-in package management support.  I'm wondering how to generate and activate autoloads for local packages?  That is similar to how package.el does it for the installed packages from ELPA.  In order to avoid reinventing the wheel, is there a way for it to "pretend" that some local directory (with subdirectories each of which is a local/custom/personal package) is ELPA?  I'm also open to el-get if such a scenario can be supported via, for example, custom recipes.

I'm sure the task is pretty common and anybody who uses Emacs on advanced level comes to that point sooner or later.  Could anybody share their experiences in this field?


texts: Is it possible to repeat the last org-mode source block's headers

texts:
Lately I have been writing a lot of literate sysadmining, writing down my thoughts as I explore systems by executing commands on them. This means that I end up writing the following boilerplate over and over again:

#+begin_src bash :dir /ssh:<some-remote-machine>:/

#+end_src

I usually just copy this snippet and bring it back from the kill ring whenever needed, but it grows tiresome if you mix this with other operations that populate the kill ring.

It would be handy if I could bring this back using some keybinding or snippet. The shell of a yasnippet doing this would look like:

#+begin_src ${1: `(some (code (finding-the-last-used-header-args)))`

#+end_src

But for my specific purposes perhaps having only the hostname being picked up would be better, like:

#+begin_src bash :dir /ssh:${1: `(code-finding-the-hostname)`:/

#+end_src

The result of invoking either one of these snippets in the same buffer as the first code example but below it would result in the exact same text being produced again.

I hope this explains what I'm looking for well enough.


texts: creating a second independent journal using org-journal

texts:
I was wondering if anyone has been able to use org-journal and create a second independent journal. Note that I use Spacemacs. I have been using org-journal for my daily journal, which is great. However, I want to create a second weekly journal to plan things out for the week. Right now org-journal bounds to C-j-j key, so I would like to have a different key combo that would open the second journal.

I was looking over the org-journal code. It looks simple enough, but was not sure if I was on the right track. If anyone can suggest a simpler way, that would be great. The original org-journal code is linked for reference.

The code for the location of journal files is. Below. So I would just have to create a second similar entry.

The first thing is to create a new keybinding:

 ;; Key bindings
 (define-key org-journal-mode-map (kbd "C-c C-f") 'org-journal-open-
 next-entry)
 (define-key org-journal-mode-map (kbd "C-c C-b") 'org-journal-open-
 previous-entry)
 (define-key org-journal-mode-map (kbd "C-c C-j") 'org-journal-new-
 entry)

Then I need to add a new location to the org-journal-dir variable to set a new directory for the second journal.

 (defcustom org-journal-dir "~/Documents/journal/"
 "Directory containing journal entries.
  Setting this will update auto-mode-alist using
 `(org-journal-update-auto-mode-alist)`"
 :type 'string :group 'org-journal
 :set (lambda (symbol value)
     (set-default symbol value)
     (org-journal-update-auto-mode-alist)))

The function for creating a new entry is below. But the variable for the journal directory is saved in the org-journal-dir variable. So it is not an argument for the function below. Hence I would just need to copy this function and reference the name of the second variable created for org-journal-dir2.

 (defun org-journal-new-entry (prefix &optional time)
 "Open today's journal file and start a new entry.
 Giving the command a prefix arg will just open a today's file,
 without adding an entry. If given a time, create an entry for
 the time's day."
(interactive "P")
(org-journal-dir-check-or-create)
(let* ((entry-path (org-journal-get-entry-path time))
     (should-add-entry-p (not prefix)))

;; open journal file
(funcall org-journal-find-file entry-path)
(org-journal-decrypt)
(goto-char (point-max))
(let ((unsaved (buffer-modified-p))
      (new-file-p (equal (point-max) 1)))

  ;; empty file? Add a date timestamp
  (when new-file-p
    (insert org-journal-date-prefix
            (format-time-string org-journal-date-format time)))

  ;; add crypt tag if encryption is enabled and tag is not present
  (when org-journal-enable-encryption
    (goto-char (point-min))
    (unless (member org-crypt-tag-matcher (org-get-tags))
      (org-set-tags-to org-crypt-tag-matcher))
    (goto-char (point-max)))

  ;; move TODOs from previous day here
  (when (and new-file-p org-journal-carryover-items)
    (save-excursion (org-journal-carryover)))

  ;; skip adding entry if a prefix is given
  (when should-add-entry-p
    (unless (eq (current-column) 0) (insert "\n"))
    (insert "\n" org-journal-time-prefix
            (if (= (time-to-days (current-time)) (time-to-days time))
                (format-time-string org-journal-time-format)
              "")))

  ;; switch to the outline, hide subtrees
  (org-journal-mode)
  (if (and org-journal-hide-entries-p (org-journal-time-entry-level))
      (hide-sublevels (org-journal-time-entry-level))
    (show-all))

  ;; open the recent entry when the prefix is given
  (if should-add-entry-p
    (show-entry))

  (set-buffer-modified-p unsaved))))

The rest would seem to stay the same. Does this seem like the right way to do this, or is there a simpler way?


texts: How to enable flycheck in every layer in spacemacs by default?

texts: I have syntax-checking in my layers, and according to the documentation, it should be enabled by default in every buffer. However, for me this is not the case. How do I enable flyspell syntax-checking by default in spacemacs?


texts: Execute command on every start except you load a file from commandline

texts:
To load helm-mini every-time when emacs starts, I use the following line in my .emacs file as suggested in https://emacs.stackexchange.com/a/26402/2323

(add-hook 'emacs-startup-hook #'helm-mini)

This in particular avoids that helm-mini is loaded if I execute eval-buffer after changing my .emacs-file.

However there is another problem with it: If I start emacs from command line like emacs myfile.tex, emacs opens the file myfile.tex but also opens helm-mini. How can I make emacs not to load helm-mini in this case?