texts: Replace full-width numerals with half-width numerals

texts:
I'd like to convert numerals from half-width to full-width characters with a simple regex search and replace as follows:

  replace-regexp-in-string regexp rep string &optional fixedcase literal subexp start

(replace-regexp-in-string '(０ １ ２ ３ ４ ５ ６ ７ ８ ９) '(0 1 2 3 4 5 6 7 8 9))

Evaluating the above code in a buffer gave me this error:

(wrong-number-of-arguments (3 . 7) 2)

I suppose the missing argument is the string, which I assumed would take care of itself when I evaluate the code using M-: on a buffer.

How do I do this correctly?

Follow-up Question:

I would like to abstract the commands given in @Tobias' answer into a single function, so that I can call them with a single key-binding.

Here's my attempt:

(defun num-half2full
    (query-replace-regexp [0-9]
              /,(string (+ (string-to-char \&) (- ?０ ?0)))))

Error:

(error "Malformed arglist: (query-replace-regexp [0-9] / (, (string (+ (string-to-char &) (- 65296 48)))))")

My last attempt at writing the function:

(defun num-full2half ()
  "Convert numbers from full-width to half-width"
  (interactive)
  (goto-char (point-min))
  (replace-regexp "[０－９]"
  (quote (replace-eval-replacement replace-quote
    (string (+ (string-to-char (match-string 0)) 48 (- 65296)))))))

The expected replacement did not take place in the buffer at which M-x<\kbd>(num-full2half) was called.


texts: highlight calender holiday with background color

texts:
In org-mode, when I press C-c C-d to add agenda, I got below screen:

It's perfect to see current day has been marked with red background, how can I mark the holidays (say 12/25) with some background color also?


texts: ggtags does not play well with tramp -- emacs freezes multiple times

texts:
I've recently started to use tramp to edit a codebase that's two ssh hops away from me I was initially very happy with the experience, given how transparent everything was.
I use magit and ggtags and, after some initial trouble, I managed to configure the environment in order for emacs to find the proper path.
However, after using this setup for some time, I noticed that ggtags and tramp really do not play along very well.
Every few seconds, when I type in some symbol that ggtags thinks it might recognize, it kicks in, calling tramp to access GTAGS and friends, making me wait for some good seconds before unfreezing emacs and letting me type again. This would be OK if it wasn't for the fact that emacs doesn't always come back. Very often, if I keep typing while emacs is frozen, things probably get into some sort of loop and it keeps frozen for wayy too long.
I'm not sure if it keeps stuck forever, but for several minutes that's for sure. To unfreeze it, I have to repeatedly hit C-g. Whenever I do this, I get a message more or less like
error in process filter: Quit

which seems to indicate that some sort of filter process is what gets stuck.
Any idea what I could do to mitigate this?
At the moment, I just disable ggtags when I'm typing in code, but that's really less than ideal, since I rely a lot on ggtags to navigate on the codebase.
I also though about downloading the GTAGS files, but I avoided doing that since these files are several GB and I also don't even know how that would work.

A little bit more about my setup
Some more details about my setup and what I've been trying out so far. The codebase I'm working on is a somewhat large C++ codebase. Compiling it in my local machine takes around 40-50min. My remote work machine is way more powerful and is able to compile it in 25-30min. Also, it has a lot more memory available, which means I don't have to keep an eye on the memory consumption like I do in my local machine.
To access my remote machine I have to, first, access the institution's ssh servers to, then, from it, access my machine and then work on it. So far, I've been using emacs through X forwarding, which works surprisingly well, but the problem is that the connection isn't always the best, given that every other employee has to access their own machine through the same ssh server. If the connection goes down, I have to kill my ssh session and reconnect to it, losing all my buffers in the process. Also, input lag can get really bad sometimes, which considerably slows me down.
To summarize, here are my options:

emacs through X forwarding, which works well, but isn't super reliable
work locally, which is the best for editing, but my computer isn't powerful enough to compile the project in a satisfactory manner
local emacs with tramp, which allows me to edit locally, but compile remotely and works pretty well, besides ggtags not playing along
local emacs pushing the code every once in a while to compile in the remote machine, which would really slow me down compared to any of the other options


texts: How to programmatically update a named org-table in-situ

texts:
It's possible to programmatically update an org table inside a babel source code block like the following:

#+name: mytable
| 0 | 0 | 0 |
| 0 | 0 | 0 |

#+begin_src emacs-lisp :var table=mytable
  (append table '((1 2 3)))
#+end_src

#+RESULTS:
| 0 | 0 | 0 |
| 0 | 0 | 0 |
| 1 | 2 | 3 |

I would like to update the original named table and discard the RESULTS output.  In the case of this code it would keep appending a row to the table each time the source block is evaluated.

I've seen org samples that name the babel source the same as the source/target table (that presumably will do this) (https://eschulte.github.io/org-scraps/scraps/2011-08-19-replacing-a-table.html), but I get an org-get-property-block: Variable binding depth exceeds max-specpdl-size error whenever the names collide.


texts: How can I disable company-mode in a shell when it is remote?

texts:
I am using (global-company-mode 1) but using remote shell it is annoyingly slow.

How can I disable company mode when I open a shell buffer, but only if it's a remote shell?

The problem manifests when I SSH to a remote server using C-x f /ssh:root@server.com:/ and then M-x shell.


texts: how to map ,  etc to the correct hex codes in iterm2

texts:
I'm looking to configure iterm2 to output the correct hexcodes that correspond to  in emacs.

There's a whole bunch of mappings predefined but it's very cryptic.

I'm a little bit lost as to how these mappings are translated and if there is a table of how these mappings work.


texts: Is Emacs using a TAGS file to locate built-in definitions?

texts:
Out of the box, my emacs build can jump to elisp function definitions. For example, I start emacs with no init file, type copy-to-buffer in the scratch buffer, hit M-., and it opens up simple.el.gz with the cursor on the defun for copy-to-buffer.

I would think this indicates there's a TAGS file somewhere that emacs is using, but I can't locate it. I checked the values of tags-file-name and tags-table-list, both of which are nil.

I searched the directory where emacs is installed (I installed with Homebrew),

find /usr/local/Cellar/ -iname *tags*

and found nothing on interest. I searched all of /usr/ as well.

What black magic is this? Does Emacs have some kind of internalized tags table for the built-in elisp libraries?


texts: How to export babel source blocks with syntax highlighting to ODT in org-mode in Emacs 27?

texts:
In Emacs 27, babel source blocks do not export syntax highlighting to ODT format.

The same org document is exported as expected in Emacs 25.

Versions:

GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-10-06

Org mode version 9.1.2 (release_9.1.2-40-g6ca906 @ /usr/share/emacs/27.0.50/lisp/org/)


texts:
I'm using the evil-search module ((evil-select-search-module 'evil-search-module 'evil-search)). When I perform a search, the results remain highlighted until I call evil-ex-nohighlight.

I'd prefer that the highlights go away by themselves after a few seconds. I tried (setq evil-ex-search-persistent-highlight nil), but this setting apparently doesn't apply to evil-search. Is there a way of having auto-expiring highlights with evil-search?


texts: What is causing this AUCTeX preview fatal error, or how can I find that out?

texts:
This is a minimal test file:

\documentclass{article}
\begin{document}
\[1+1=2\]
\end{document}

The content of texput.log is the following:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.10.7)  23 OCT 2019 23:49
entering extended mode
 restricted \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi} \input {\detokenize{ _region_.tex }}^^M

! Emergency stop.
<read *>

<*> ...5]\fi} \input {\detokenize{ _region_.tex }}
                                                  ^^M
*** (cannot \read from terminal in nonstop modes)

Here is how much of TeX's memory you used:
 8 strings out of 492166
 160 string characters out of 6125377
 59039 words of memory out of 5000000
 4473 multiletter control sequences out of 15000+600000
 3640 words of font info for 14 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 5i,0n,6p,268b,10s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

The problem appeared after one time I ran brew upgrade in terminal. I guess it is because the latest ghostscript has some incompatibility issue with AUCTeX. I have searched a lot and tried a lot. Here are what I have done:

I use Mac. There is a known problem with the path of ghostscript. This line is in my init file: (setq preview-gs-command "/usr/local/bin/gs"). It should be correct.
I have tried to manually install old versions of ghostscript, like 9.21 or 9.25. They used to solve the problem, but not this time.
I uninstalled ghostscript installed with brew and manually installed 9.25. Not working.

System: MacOS Catalina 10.15
Emacs: GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-09-02
AUCTeX: 12.1.2
ghostscript: 9.25


texts: Replace word at point preserving the case pattern

texts:
Currently, I am doing the replacement of the word under the cursor on a script using:

(setq bounds (bounds-of-thing-at-point 'word))
(setq pos1 (car bounds))
(setq pos2 (cdr bounds))
(delete-region pos1 pos2)
(insert newword)

But this does not preserve the case pattern of the original word. The function replace-match would preserve case, but it would require me to do a search before; something like this:

(left-word)
(search-forward originalword)
(replace-match newword)

Is there a replace command which would allow me to replace the word at point preserving the original word pattern case? If not, am I missing a simple way to write one?


texts: error: Package `xah-fly-keys-' is unavailable

texts:
I am setting up a .emacs file that I will be using in Docker containers.

I want to include xah-fly-keys but I am getting this error message.

Package `xah-fly-keys-' is unavailable

When I start Emacs in a container I want xah-fly-keys to automatically be installed and activated.

xah-fly-keys is in melpa

The relevant parts of the .emacs file are:

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

;; Initialise packages
(package-initialize)

;; require use package
(package-install 'use-package)

;; add xah-fly-keys
(use-package xah-fly-keys
  :ensure t
  :pin melpa-stable)

;; activate xah-fly-keys
(xah-fly-keys 1)

What do I need to do to get this working?


texts:
When I've launched vc-annotate and then type a (vc-annotate-revision-previous-to-line), emacs will show me the revision before the one on the current line.

From the docs:

  a

  Annotate the revision before the one indicated by the current line.
  This is useful to see the state the file was in before the change on
  the current line was made.

After doing this, I now want to go back to the previous revision of the file that I was viewing before I pressed a. How can I do this?

If emacs vc-annotate doesn't support it natively, are there any packages that can accomplish this? Or how would I go about coding this on my own? I imagine I could just use some sort of stack to store all the revisions visited in the current vc-annotate session, and then pop one off using an undo command.

I am using git, so would even be interested in an answer that applies only to git.


texts: I'm using emacs 25.1.1 with the prelude config. In Atom I used to have a setting that made my lines wrap at 80 characters (without cutting words) for better readability. I've searched on the web for something similar for emacs but I have not found anything. Any ideas on how to do this?


texts: The shift is useless when I am in the iterm2 with emacs -nw

texts:
GNU Emacs 24.5.1 (x86_64-apple-darwin14.5.0

Org-mode version 8.2.10 (release_8.2.10

For example, when I use C-q M-Return. It shows ^[ .
But when I use C-q  M-S-Return. It still shows ^[ . It seems S: Shift is useless.


texts: How to highlight text in org-mode with per-buffer settings

texts:
I know that it is possible to change the face used to display markup (bold, italic, etc.) in org-mode, just as explained here.

However, I would like to know if it is possible to have this kind of settings activated for just one particular buffer, instead of having it activated for all org-mode buffers. In other words, I'm looking for a per-buffer setting for special text highlight in org-mode.

I'm a language teacher and I have dictionaries in org-mode format; it would be great to have special highlight for the different parts of a word entry based on the org-mode markups.  On the other hand, naturally I do have also personal notes in org-mode, and for those notes I want the org-mode markups just the way they are.

Thanks for your help.


texts: How to install and use exwm (the emacs based window manager) in Ubuntu 19.04?

texts: I am running Ubuntu 19.04 on my laptop and want to use EXWM as my window manager, but am not sure how to get it into the list of window managers that one can pull down when one logs in.  It seems to only list "officially supported" ones.


texts:
I've seen a discussion on someone trying to save the actual state of a Lisp Slime REPL. I just want to save a text version of a Geiser Racket REPL session, e.g., *ch1*, while using org-mode. (Then I can add it to my git.) Could someone point me to some elisp that would create the text file with a name that contains the session name, date-time stamp and file ending ".repl"? I've looked at elisp ref talk about "saving buffer," but it doesn't seem to have what I want.

I say all this because just trying to do a C-x C-s will indeed give me a text version of REPL session *ch1*, but it renames the live *ch1* REPL buffer to whatever I'm calling the text version, e.g. ch1-12112016-11:04.repl ... which is cool but not what I need. (BTW, the org-mode/geiser system doesn't get confused. It still uses that REPL session even though it's been renamed.) Again, I just want to save off a text version of what's in the REPL buffer with a timestamp and .repl ending.


texts: How to list or autocomplete pandoc-crossref citations in an org-mode buffer?

texts:
Is there a way to autocomplete when typing a pandoc-crossref style references such as {#fig:foo} or #+LABEL: fig:foo ?
Currently, I have to remember all these names/labels in the org-mode buffer and manually type [@fig:foo] per In org mode, how do I reference a figure?. And it is becoming unmanageable with many such labels.
So, basically, I was looking for a way to autocomplete (or get a list of) all labels that can be referred to by [@fig:foo].


texts:
I am trying to use ein with org-mode in emacs but I am having problems with exporting the results. Here is a very simple example:

#+BEGIN_SRC ein-python :session localhost :results raw drawer :exports both
  import pandas as pd
  x = pd.DataFrame({'Num': a, 'Text': ['a', 'b', 'c', 'd']})
  x
#+END_SRC

:results:
   Num Text
0    1    a
1    3    b
2    5    c
3   12    d
:end:

So, using :results raw drawer writes the results inside :results: block, and are not shown when I export to html. If instead I use :results output or :results value it simply prints [...] (no data). And :results raw prints the following

#+RESULTS: b2757239-e41b-4626-9aef-d2abf968c1ee
   Num Text
0    1    a
1    3    b
2    5    c
3   12    d

   Num Text
0    1    a
1    3    b
2    5    c
3   12    d

[....]

[....]

Which of course does not look good in the html file. The question, what is the best way to print results to export in html?


texts: How to enable pabbrev-mode only in normal text file

texts: I want to enable pabbrev-mode for the auto completion only in normal text file (.txt) because if for example I'm editing a .c source file I already have a package that do this. How can I modify the .emacs file to proper handle this issue? Or is there another package that only works on text file?


texts:
I'm interested in mount/umount usb and other devices directly from emacs.

In many file mangers (like nautilus) the devices are automatically discovered and indicated with an icon, it's possible to do something smart for emacs (maybe in dired)?


texts: Equivalent of `shopt -s autocd` in eshell

texts: I use shopt -s autocd in the bash shell. It allows me to just type in the directory name and cd there. Is there some equivalent in eshell?


texts: how to define a key binding that includes input to the minibuffer?

texts:
I am frequently running multiple Emacs servers. When I am in a particular client I sometimes want to check which Emacs server I am connected to.

So I do:

`C-h v`

… and the enter in the mini-buffer server-name.

Is there a way to define a keybinding that also includes the input that should be entered in the mini-buffer?


texts: Equivalent to `ido-find-file` functionality for ivy/counsel?

texts:
I really like how ido-find-file, if it can’t find a file matching your string (and you’ve let it idle for like a second), will search your whole home directory for files matching that string, and then your whole directory tree. (At least, I think that’s how it works. I’ve never been able to untangle the code.) I’m hoping there’s an equivalent to that functionality in ivy/counsel, like for counsel-find-file, but I haven’t found it.

This is similar to this question: What's the equivalent of `helm-find` in ivy/counsel? I want to find files **recursively** … but not exactly. I think? I’ve never used helm. I’m glad to know of counsel-file-jump, but it’s too slow up front for what I need since it doesn’t do that gradual ratcheting that ido-find-file does.


texts: What keystrokes are required to navigate back from the bash shell to the editing windows?

texts:
I have configured the spacemacs "shell" layer and set it up with multi-term to use the bash shell. When I activate it with SPC ' and enter the bash shell some of the keys like Ctrl-w used for navigating the windows are trapped by bash.

   dotspacemacs-configuration-layers
   '(
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     helm
     auto-completion
     emacs-lisp
     git
     markdown
     org
     syntax-checking
     elixir
     erlang
     ;; better-defaults
     (shell :variables
            shell-default-shell 'multi-term
            shell-default-height 30
            shell-default-position 'bottom)
     ;; spell-checking
     ;; version-control
     )

(defun dotspacemacs/user-config ()
  (setq multi-term-program "/bin/bash")
  )

Are there some pre-existing key combinations that can be used instead?


texts: Ergoemacs cuts selected region when I try to change buffer

texts: When I command eval-region to a highlighted area, I would like to quickly change to another buffer with C-x b to see the result. However, the first part of this key combination cuts the selected code, even when another shortcut M-x does the same thing. Is there a way to disable the keybinding for C-x wihtout losing the associated functionality of C-x b?


texts:
I am able to compute dates thus:

#+NAME: mytbl
| # | [2014-12-14 Sun] | 30 | <2015-01-13 Tue> |
#+TBLFM: $4=$2+$3;D

but what I want to then do is make that date appear as an agenda date, something like:

DEADLINE: $remote(mytbl,@1$4)

but that doesn't work. I can't find any syntax, even a macro, that will allow anything but a literal date for an agenda entry.

Any ideas?


texts: company doesn't pop up completion list automatically

texts:
I'm trying to get company mode to automatically trigger the pop-up with a list of possible completion. Unless I'm doing this wrong this is not the default behaviour? Current I have to run M-x company-complete manually.

I am not interesting in binding it to a key. I want the idle-completion behaviour. I'm using this with rustic (rust-mode fork).

Steps to reproduce:

Start from fresh emacs

[ -e ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.d.bak
mkdir ~/.emacs.d && cat <<'EOT' > ~/.emacs.d/init.el
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")))

(require 'package)
(package-initialize)
EOT

Start Emacs
Install packages (from MELPA): lsp-mode, company, rustic
Install rustup (instructions at https://rustup.rs )
Install additionnal components: rustup component add rls rustfmt rust-src
Create new test project: cargo new rtest
Add the following to init.el:

(defun my-rust-hook ()
  (require 'company)
  (setq company-minimum-prefix-length 2)
  (setq company-idle-delay 0)

  ;; conf 1
  ;(setq company-auto-complete nil)
  ;; conf 2
  (setq company-auto-complete t)
  (add-to-list 'company-auto-complete-chars (char-syntax ?:))

  (company-mode 1)
  )

(eval-after-load 'rustic
  '(progn
     (require 'lsp)
     (when (not (require 'yasnippet nil 'no-err))
       (setq lsp-enable-snippet nil))
     (add-hook 'rustic-mode-hook 'my-rust-hook)))

Restart emacs
Open rtest/src/main.rs
Type:

use std::env;

fn main() {
    // place point here at the end
}

Type env:: and wait. Completion menu doesn't show up.
You can try conf 1 or 2 from the init.el but you will see same result.
Running M-x company-complete works and shows the menu but idling doesn't.


texts: How to find START and END of #+RESULTS region with elisp functions?

texts:
I want to call (recode-region) on sh code block results in :post header attribute.
So it needs START and END values. Is there a way to define of RESULTS block content boundaries for it ?


texts:
Looking at this, I see

(setq x '#1=(a #1#))

but this evaluates to (a #0). As I understand, this should be (a #1=(a #1#)). But then what syntax makes #0 mean #1=(a #1#)? In general what is # doing in the original setq form, then the returned list (a #0)?

Playing around, I see (cadr (cadr (cadr x))) always returns (a #0) which makes sense, but deepens the mystery.


texts:
I am trying to write a global minor mode.  The following illustrates my problem:

(define-minor-mode global-foo-mode :global t :lighter " FOO")

then run

M-x global-foo-mode

The message displayed is

Global-Foo mode disabled

The current buffer does not display the FOO lighter in its mode line, but every other buffer does.  Subsequent invocations of M-x global-foo-mode in various buffers seem to enable and disable the mode on the current buffer, but not globally as I would expect.  Can anyone help me understand what I'm doing wrong here?


texts: Is there a common way of exporting Org mode tasks to sqlite?

texts: I would like to export tasks from Org file to a middle file in order to convert it later to other back-ends. Should I use CSV format, database format or is there a common parser for this type of tasks?


texts: Having switched to sbcl, slime asks for *inferior-lisp* confirmation during close

texts:
I was using clisp with Emacs-25.2 on Windows XP and Emacs-25.3 on Windows 7. Because sbcl has better trace support I switched to sbcl-1.4.14 on both  Windows XP and 7. Both machines have slime-20180804.1655 installed. When I close slime(using the command sayoonara) I get

Buffer "*inferior-lisp*" has a running process; kill it? (yes or no)

and I have to manually enter yes

I looked into the slime folder if there's a file like stop-swank.lisp or similar, there was none. How do I fix it? Thank you.


texts:
I would like to sum clock intervals from tasks by tag. I found this blog post (code below). When I use it, I get the same report, regardless of the tag I request:

Time: 4499:28 (4499 hours and 28 minutes)

Furthermore, I get this warning after evaluating the code:

‘org-re’ is an obsolete macro (as of Org 9.0); you can safely remove it.

The post is from 2008 and therefore I assume that the code is incompatible with my version.

How can I sum clocked intervals for a specific tag?

Appendix: here is the obsolete code:

(defun wicked/org-calculate-tag-time (matcher &optional ts te)
  "Return the total minutes clocked in headlines matching MATCHER.
MATCHER is a string or a Lisp form to be evaluated, testing if a
given set of tags qualifies a headline for inclusion. TS and TE
are time start (inclusive) and time end (exclusive). Call with a
prefix to be prompted for TS and TE.

For example, to see how much time you spent on tasks tagged as
URGENT, call M-x wicked/org-calculate-tag-time RET URGENT RET. To
see how much time you spent on tasks tagged as URGENT today, call
C-u M-x wicked/org-calculate-tag-time RET URGENT RET . RET +1 RET."
  (interactive (list
        (read-string "Tag query: ")
        (if current-prefix-arg (org-read-date))
        (if current-prefix-arg (org-read-date))))
  ;; Convert strings to proper arguments
  (if (stringp matcher) (setq matcher (cdr (org-make-tags-matcher matcher))))
  (if (stringp ts)
      (setq ts (time-to-seconds (apply 'encode-time (org-parse-time-string ts)))))
  (if (stringp te)
      (setq te (time-to-seconds (apply 'encode-time (org-parse-time-string te)))))
  (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
             (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
             (org-re
              "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:][email protected]:]+:\\)?[ \t]*$")))
     (case-fold-search nil)
         lspos
     tags tags-list tags-alist (llast 0) rtn level category i txt p
     marker entry priority (total 0))
    (save-excursion
      (org-clock-sum ts te)
      (goto-char (point-min))
      (while (re-search-forward re nil t)
    (catch :skip
      (setq tags (if (match-end 4) (match-string 4)))
      (goto-char (setq lspos (1+ (match-beginning 0))))
      (setq level (org-reduced-level (funcall outline-level))
        category (org-get-category))
      (setq i llast llast level)
      ;; remove tag lists from same and sublevels
      (while (>= i level)
        (when (setq entry (assoc i tags-alist))
          (setq tags-alist (delete entry tags-alist)))
        (setq i (1- i)))
      ;; add the nex tags
      (when tags
        (setq tags (mapcar 'downcase (org-split-string tags ":"))
          tags-alist
          (cons (cons level tags) tags-alist)))
      ;; compile tags for current headline
      (setq tags-list
        (if org-use-tag-inheritance
            (apply 'append (mapcar 'cdr tags-alist))
          tags))
      (when (and (eval matcher)
             (or (not org-agenda-skip-archived-trees)
             (not (member org-archive-tag tags-list))))
        ;; Get the time for the headline at point
        (goto-char (line-beginning-position))
        (setq total (+ total (or (get-text-property (1+ (point)) :org-clock-minutes) 0)))
        ;; if we are to skip sublevels, jump to end of subtree
        (org-end-of-subtree t)))))
    (if (interactive-p)
    (let* ((h (/ total 60))
           (m (- total (* 60 h))))
      (message "Time: %d:%02d (%d hours and %d minutes)" h m h m)))
    total))


texts: I was wondering if it is possible to convert the echo area into something like what you get when you press C-f after : (in ex-mode)? One of the packages I am using gives me a modifiable (long) string of a command and its arguments, it would be easier to edit in normal state.


texts:
Using the GUI version of emacs, I would like to the fonts to match the rest of my system.

I have changed my the font to the same as my terminal font, but the anti-aliasing makes it look much different.

Is there anyway to disable anti-aliasing from emacs for the X server version?

Or do I need to look into fonts.conf or something similar?

I am using Fedora 23 and emacs-24.5.


texts: Function to paste text as a orgmode table

texts:
I'm wondering if anyone knows of a way to have a function (that I can bind to a key) that pastes the current text in the clipboard as a formatted org table?

Also as a bonus (since this is used to create as ingredients table for a cookbook) it would be great to be able to define the columns in advance so that the amount|type|ingredients are nicely separated. For example take this list

3/4 cup milk
2 tablespoons white vinegar
1 cup all-purpose flour
2 tablespoons white sugar
1 teaspoon baking powder
1/2 teaspoon baking soda
1/2 teaspoon salt
1 egg
2 tablespoons butter, melted
cooking spray

If I mark this as a region and issue org-table-create-or-convert-from-region this is the result

|     3/4 | cup         | milk        |         |      |        |     |       |         |
|       2 | tablespoons | white       | vinegar | (%or | better | yet | lemon | juice%) |
|       1 | cup         | all-purpose | flour   |      |        |     |       |         |
|       2 | tablespoons | white       | sugar   |      |        |     |       |         |
|       1 | teaspoon    | baking      | powder  |      |        |     |       |         |
|     1/2 | teaspoon    | baking      | soda    |      |        |     |       |         |
|     1/2 | teaspoon    | salt        |         |      |        |     |       |         |
|       1 | egg         |             |         |      |        |     |       |         |
|       2 | tablespoons | butter,     | melted  |      |        |     |       |         |
| cooking | spray       |             |         |      |        |     |       |         |

As you can see it got the amount (1/2) and the unit (cup) right yet the actual ingredients is cut into several columns.

I don't really know how to deal with this. Is there a more intelligent way of auto directing the conversion to split it the correct way?


texts: How can I set web-mode to use comment-dwim?

texts:
I want web-mode to use comment-dwim instead of web-mode-comment-or-uncomment (bound to M-;).

I tried:

;; Web Mode (http://web-mode.org/)
(with-eval-after-load 'web-mode
  (setq
   web-mode-markup-indent-offset 2
   web-mode-css-indent-offset 2
   web-mode-code-indent-offset 2)
  ;; (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  (global-set-key (kbd "M-;") 'comment-dwim))

But the change doesn't apply, I've also tried with local-set-key.


texts: Are there any Emacs libraries for encoding protocol buffers?

texts: I've found a mode for editing protocol buffer definitions but I'm looking for a library to serialise and de-serialise the wire protocol itself.


texts: Is there a way to have ivy display a tooltip for the function at point?

texts: Ie, suppose I press M-x org-agenda and ivy says there's 131 matches, of which I recognize maybe 10. It'd be useful to say, after a .2 second delay, display a tooltip for the function at point. Is there a way to do that?


texts: Timer runs immediately then periodically

texts:
I have a timer I want to run every day at 4am. Thus, I put something like this in my configuration.
(defvar my/timer nil)
(unless my/timer
  (setq my/timer (run-at-time "04:00am" (* 24 60 60) #'my/function)))

This works as expected, except that each time this snippet is evaluated for the first time (e.g., when launching emacs),  my/function is executed immediately. In fact, evaluating (run-at-time "04:00am" (* 24 60 60) #'my/function) at any time in the day causes this effect.
Maybe I have a misunderstanding, but isn't it supposed to run only at the specified time ?


texts:
I'd like to export from a large orgmode file a subtree, which looks like this:

* Subtree to be exported
:PROPERTIES:
:EXPORT_FILE_NAME: "C:/PATH/TO/FOLDER/filename.org"
:EXPORT_TITLE:
:END:

foo

Error message after C-c C-e C-s h h : »Output file not writable«. How can I add a path to the filename? orgmode 8.3.2


texts: How to disable some rules of an input method?

texts: I use purescript-unicode-input-method in Purescript.  However, I want the input method not to translate ->, ~> and => because their Unicode characters look very similar.  Is there a way to disable certain rules of an input method?


texts: How to check if a directory exists in elisp?

texts: I've seen how to check if a file exists (file-exists-p), but how to check if a directory exists?


texts: Elisp: sorting SYM VAL pairs in a setq expression

texts:
I wrote a rather clunky elisp function to sort the SYM VAL args in a setq expression alphabetically by SYM. For example:

(setq c "blah"              (setq a 9
      b '(more stuff)  -->        b '(more stuff)
      a 9)                        c "blah")

After reading about sort-subr, I thought I might be able to build a cleaner implementation. I thought I had it, but something's not right. What am I doing wrong here?

(defun sort-setq ()
  (interactive)
  (save-excursion
    (save-restriction
      (let ((sort-end (progn (end-of-defun)
                             (backward-char)
                             (point-marker)))
            (sort-beg (progn (beginning-of-defun)
                             (re-search-forward "[ \\t]*(" (point-at-eol))
                             (forward-sexp)
                             (re-search-forward "\\<" (point-at-eol))
                             (point-marker))))
        (narrow-to-region (1- sort-beg) (1+ sort-end))
        (sort-subr nil #'sort-setq-next-record #'sort-setq-end-record)))))

(defun sort-setq-next-record ()
  (condition-case nil
      (progn
        (forward-sexp 3)
        (backward-sexp))
    ('scan-error (end-of-buffer))))

(defun sort-setq-end-record ()
  (condition-case nil
      (forward-sexp 2)
    ('scan-error (end-of-buffer))))

It seems to work for the 3-pair example above, but if I start adding more pairs it fails to sort them all.


texts: Like pressing "q", but from the other window

texts:
I run a command that takes over another window, and maybe resizes it a little, but doesn't focus it. Let's say C-h e or C-x C-b.
I can go to that window and press q there, and everything goes back to the previous state (the window resizes back, its previous content is restored, focus is back to the original window).
I want to be get the same effect without having to go to that window. Instead of C-h e C-x o q I want to be able to do C-h e <some keystroke that will close the most recently opened closeable-by-pressing-q window>.


texts: Minibuffer prompt not displaying (intermittently) in daemon mode

texts:
I am using Emacs 24.5 on Mac OS (installed with homebrew) in daemon mode. I normally leave the daemon running for long periods of time (weeks) while I'm working. I'll open up files from the command line using emacsclient -n.

I've noticed is that emacsclient will block if opening the file causes a minibuffer prompt. For instance, if I've already got the file open and the file on disk differs from the file in the associated buffer. 99% of the time, I just switch to emacs, answer yes (or sometimes no) and everything works perfectly.

However, intermittently, emacsclient will block, as will the emacs GUI, but no minibuffer message will be displayed. My only option at this point seems to be killing the daemon. It's almost as if the minibuffer message is being displayed on a non-existent frame (I often work with multiple frames).

Two questions:

Does anyone know what's going on here - and perhaps a way to prevent it?
Is there a way to unblock a blocked emacs daemon? C-g from the GUI isn't having any effect.


texts: How to show other files and subdirectories in current dired file buffer?

texts:
If I open dired buffer with filename as parameter, and not directory, only that one file is displayed in dired mode. But I wish I could open dired buffer like that (dired "/usr/bin/pwd") and see not only one pwd entry, but all other files and subdirectories, and cursor will be on pwd.

That is the default behavior of dired-jump, and I wish I could somehow do the same for ordinary filepath, and not current buffer.


texts: Poor display quality with pdf-tools after system update

texts:
I am using manjaro operating system. After the last system update I noticed a somewhat annoying  thing when viewing pdf files in emacs with pdf-tools. The rendering quality become poor and the image is blurry. Does anyone has a suggestion on how to fix this.
Thanks in advance!


texts: Is there a way to mark certain file types as binary for magit, so that they are not diffed?

texts:
Magit sometimes becomes very slow, when it thinks that certain large files should be diffed.  Examples for this are SVG graphics or SQL dumps (technically seen as text files).  The files are small enough that they should be controlled by git, but seemingly too large (and with very long lines) for magit to display.
Is there a way to tell magit not to create the diff for certain file types?  Maybe something like a blacklist?


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

 Symbol's function definition is void: this

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


texts: How to set a key binding conditional to evaluate a Lisp expression

texts:
I am thinking of binding C-x C-e to a single command, which does eval-last-sexp if there is no selection or eval-region if there is a selection. This is what I have tried:

(defun my/eval()
(interactive)
(if (region-active-p) (eval-region region-beginning region-end)
(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)))
(global-set-key (kbd "C-x C-e") 'my/eval)


texts: Emails sent twice in mu4e with send-delay

texts:
I send emails with delay using mu4e-send-delay. The repo seems out of date with the last commit 2 years ago.

I often find that emails I sent with delay are sent twice, for example a pair sent within 1 minute of each other:

Date: Mon 29 Apr 16:05:09 2019
Date: Mon 29 Apr 16:04:17 2019

an another pair within 1 second of each other:

Date: Tue 30 Apr 12:51:22 2019
Date: Tue 30 Apr 12:51:21 2019

And some pairs have exactly the same timestamp.

Nevertheless, some recipients I contacted only receive one of them.

In addition, attachments show differently, for example one email in the pair has:

Date: Mon 29 Apr 11:56:01 2019
Maildir: /Sent Items
[...body of email...]
<#part type="application/pdf" filename="/var/folders/zx/j_gjm0ld081b_mcqmg3gp9l1zp59y6/T//mu-2137171910/9ca95bbc/3/SS Programme 2019.pdf" disposition=attachment>
<#/part>

and another in the pair has:

Date: Mon 29 Apr 11:55:41 2019
Maildir: /Sent Items
Attachments: [1]SS Programme 2019.pdf(1.1M)
[...body of email...]

This thread mentions a similar behavior with mu4e, not mu4e-send-delay, and the fix is:

(setq mu4e-sent-messages-behavior 'delete)

How can I fix this in mu4e-send-delay?


texts: Split a string without consuming separators?

texts:
I frequently need to split strings, while keeping the separator. Researching the elisp manual, I am not finding a way to split a string according to a separator, without consuming the separator itself.

For example, split-string splits a given string into substrings based on the regular expression separators, but the substrings lose the separator:

(split-string "* one * two * three" "\*")

returns:

("" " one " " two " " three")

I could use s-slice-at, from @magnars s.el

(s-slice-at "\*" "* one * two * three")

("* one " "* two " "* three")

I could also try to rewrite split-string myself. Still, I was wondering if there is a built-in way to do it as part of Emacs core?

If not, could somebody please point to a good way to do that properly?


texts: How can I map over a vector and get a vector?

texts:
The only thing I've found that works is

(eval `(vector ,@(mapcar #'1+ [1 2 3 4])))
=> [2 3 4 5]

but that seems far too complicated to be the 'right' way.


texts:
Q: how do I rotate PDFs in pdf-tools?

Sometimes, I want to rotate a PDF page to toggle between portrait
and landscape.  This comes up in two common settings:

An academic article has a wide table/figure typeset 90 degrees
to portrait.
I've scanned a book chapter with two book pages to a PDF page,
and the two book pages are set side-by-side in landscape.

How do I rotate pages 90 degrees?


texts: How to keep magit from prompting me for my GitHub username

texts:
I'd like to configure magit so that it does not prompt me for my GitHub username when it needs to interact with GitHub in some way (like, say, when doing a push).
My GitHub username is already in the github.user elisp variable and git variable, which should be enough according to the ghub documentation, but for some reason it keeps prompting me for my username every time I push.
magit gets my password from an external program which prompts me for my gpg key password which is used to decrypt my GitHub password in pass, and that part works fine.
I also have forge set up to use pass, and when using forge functions from magit I'm not prompted for my username, and only prompted for my gpg key password which decrypts my GitHub password in the same way it does for magit.  So if forge could be set up not to prompt for my username, I'd expect there should be some way to configure magit act the same.
Here is my setup:
In my emacs config:
(require 'auth-source-pass)
(setq auth-sources '(password-store))
(add-hook 'magit-process-find-password-functions
          'magit-process-password-auth-source))
(setq github.user "myusername")

From a shell, I typed:
git config --global github.user myusername

So now my ~/.gitconfig contains:
[github]
    user = myusername

My ~/.password-store directory tree looks like this:
.
├── api.github.com
│   └── myusername^forge.gpg
└── github.com
    └── myusername.gpg

I also tried sticking ^magit after myusername and putting both of these variations under api.github.com, like the forge entry was, but that didn't help.


texts: How do I make Emacs not complain about not being able to start a new server?

texts:
I use the mac port version of emacs for handling org-protocol URLs, because I need a graphical instance when I use org-protocol from Chrome. The problem is that emacs will try to start an emacs server whenever it receives these org-protocol requests, but I already have an emacs server running using a terminal-instance emacs. I can't just let the graphical instance be the server, as that makes me unable to use emacsclient from the terminal with the error *ERROR*: Not using an ASCII terminal now; cannot make a new ASCII frame.
Everything works fine though, if I just ignore the warning about the server:

So is there any way to get rid of that popup?


texts: Edit file as root over when already using TRAMP

texts:
Right now, I have the following in my init

(defun my-edit-file-as-root ()
  "Find file as root"
  (interactive)
  (find-alternate-file (concat "/su:root@localhost:" buffer-file-name)))

(defun my-edit-file-as-root-maybe ()
  "Find file as root if necessary."
  (unless (and buffer-file-name (file-writable-p buffer-file-name))
    (when (y-or-n-p "File is not writable. Open with root? ")
      (my-edit-file-as-root))))

(add-hook 'find-file-hook #'my-edit-file-as-root-maybe)

(a distant child of this code)

Unfortunately, this obviously doesn't work if I'm already using TRAMP (because it blindly concatenates the /su... at the beginning).

I don't know TRAMP internals well enough to determine how to flexibly parse TRAMP filenames and determine what to add to get root access.

How can I modify this to work when already using TRAMP (possibly with multi-hops already in use)?


texts: I configured my Emacs 27.2 under Windows for python with ein. As you can see the attached picture, the selection isn't disappeared!


texts: Backspace strange behaviour when word selected and cursor after open parenthesis

texts:
I got a strange issue when I hit backspace while some text is selected and my cursor is close to an open parenthesis, example:

b(aaa)

If I select aaa and my cursor is on the first a, I would like the full aaa string to be removed when I hit backspace. In other words I want this:

b()

But I get that:

b)^?

where ^? is in a different colour (may be a special character).

I suppose that the problem may come from some options or plug-in that I have like the fact that peered parenthesis are highlighted when the cursor is on it, or the command M-<dir> that move the cursor to the other parenthesis... I don't know.

Problem is the same whit " peers symbols or any peers symbols regarding the language that emacs detect. For example in C the problem is present with (``"``{ etc...

Any ideas?

EDIT:

Problem is the same with

vi(is better)

If I want to delete both words in the parenthesis


texts: Turn case sensitivity off in regular expression replacement

texts:
Converting a subversion repo to git, and setting up an authors file. I'm running query-replace-regexp on this text:

E001234

using this regexp:

^\(.*\)$ -> \1 = Some Lowercase Text Here <email@example.com>

When I execute the replacement, the replacement text is being capitalized like this, due to the case sensitive nature of replacements:

E001234 = SOME LOWERCASE TEXT HERE <EMAIL@EXAMPLE.COM>

I understand what's happening, but is there a way to turn this off w/o writing a custom function (trivial, but still...)?


texts: Emacs Dired `C-x C-j` opens a new frame instead of a new window

texts:
I am using Aquamacs 3.3  GNU Emacs 25.1.1 and Dired+. Sometimes the key sequence C-x C-j opens the Dired buffer in a new frame instead of a new tab in the running frame.

I want the behaviour that the the Dired buffer is opened in a new tab always.
What can I do?


texts: Build a minimal Emacs 25 for unit testing

texts:
I would like to build a very minimal variant of Emacs trunk for unit-testing my Emacs Lisp package.  The build needs no GUI, no image support, etc.  It should should essentially just be a minimal Emacs Lisp interpreter with the core Emacs Lisp libraries, and it should build fast, ideally in less than five minutes.

Currently, I'm passing --with-x-toolkit=no --without-x --without-all to ./configure.  After it has finished, it tells me that all Emacs features are disabled, but unfortunately the build still takes almost ten minutes.

I understand that it might be impossible to get Emacs build faster, but what makes me wonder is that with the very same flags Emacs 24.5 builds in just about two minutes.

What is the reason for this gross difference, and can I get Emacs trunk to build as fast as Emacs 24.5?

And, in a related question, how to I get Emacs to build quietly?  Currently almost 80% of my unit test output is Emacs building.  Ideally, I'd like to have make install printing no output at all.


texts:
After enable scheme in babel and restart the emacs,

Run the codes

#+BEGIN_SRC scheme
(define (A x y)
  (cond ((= y 0) 0)
        ((= x 0) (* 2 y))
        ((= y 1) 2)
        (else (A (- x 1)
                 (A x (- y 1))))))

(A 1 10)
#+END_SRC

It report error

  Symbol’s value as variable is void: geiser-default-implementation

Updated:

Installed but still report the same errors

$ scheme --version
MIT/GNU Scheme microcode 15.3
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Image saved on Saturday November 3, 2018 at 3:12:23 PM
  Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116

Moriturus te saluto.


texts:
I have two overlays that are initially in the same position.
(defvar-local minibuffer-overlay nil)
(defvar-local minibuffer-overlay2 nil)

(defun minibuffer-advice (fn &rest args)
  (minibuffer-with-setup-hook #'minibuffer-setup (apply fn args)))

(defun minibuffer-setup ()
  (setq minibuffer-overlay (make-overlay (point-min) (point-min) nil t nil))
  (setq minibuffer-overlay2 (make-overlay (point-min) (point-min) nil t t))
  (add-hook 'post-command-hook #'minibuffer-exhibit nil 'local))

(defun minibuffer-exhibit ()
  (move-overlay minibuffer-overlay (minibuffer-prompt-end) (minibuffer-prompt-end))
  (overlay-put minibuffer-overlay 'before-string "!")
  (move-overlay minibuffer-overlay2 (point-max) (point-max))
  (overlay-put minibuffer-overlay2 'after-string "?"))

(advice-add #'completing-read-default :around #'minibuffer-advice)

M-x looks like M-x ?!| where | is the cursor.
If I type foo then it becomes M-x !foo?|.
How do I make M-x initially look like M-x !?| instead?
EDIT:
Example for a *scratch* buffer since it may be confusing having it in the minibuffer:
(let ((overlay1 (make-overlay (point-min) (point-min)))
      (overlay2 (make-overlay (point-min) (point-min))))
  (move-overlay overlay1 (point-min) (point-min))
  (overlay-put overlay1 'before-string "!")
  (move-overlay overlay2 (point-min) (point-min))
  (overlay-put overlay2 'after-string "?"))

The beginning of the buffer will look like ?!. Why does the second overlay come first and how can I change that?


texts:
Helm opens buffer using a vertical split by default.

I want the Helm buffer to open using a horizontal split by default.

I can use C-t (helm-toggle-resplit-and-swap-windows) to manually toggle the position, but how can I make this change permanent?


texts: how to prevent faces from bleeding onto surrounding areas of buffer?

texts:
Q: How do I keep org-mode link faces from bleeding over into the ... selective display characters at the end of a folded header?

This is a visual tick that drives me a little nutty.  When, in org-mode, a link is the very last thing on a line, the link face bleeds over into the ... that indicates that the header is folded up.  If there is, say, a blank space after the link, there is no bleeding.

The screenshot I've posted demonstrates the issue.  Line three is the problematic line with no characters between the end of the link and the end of line, while line four shows a link, followed by a space:

First of all, why does this happen?  Second, and more to the point, how do I make it stop?

UPDATE 1: As per comments, posted below are screenshots of the buffer with the headers closed and open.  I've opened Emacs with no init file (ie, emacs -Q), required org-mode, and opened this example file.  So: it does not appear to be something kooky in my setup.

All headers closed:

All headers open:

The theme I'd been using above is inkpot, although I get the same problem when using the solarized theme as well as the default theme (as in the new screenshots).

Emacs version is 24.3.1.  I get the same results when using org version 7.9.3f (ie, the one bundled with that Emacs version), as well as 8.3beta.

UPDATE 2: here's a minimum working example in response to a comment request:

* here's a header with a [[~/somefile.txt][link at the end]]

  - This one's a problem
  - Interesting note:
    + put the cursor immediately *after* the *d* in "end" with the
      header closed/folded
      * the face no longer bleeds over into the dots
    + move the cursor anywhere else
      * the face bleeds over into the dots again

* here's another [[~/someotherfile.txt][go at it]]
  DEADLINE: <2014-10-26 Sun>

  - This one's also a problem

* here's another header with a [[~/anotherfile.txt][link followed by a space]]

  - No bleed-over onto the dots with this one


texts: Having trouble pinpointing this error wrong argument listp 1

texts:
I'm having trouble finding where the problem here is exactly. The result I'd like returned is a string that looks like

1. (n,adj-no) occupation
2. business

My function is here and it looks like something is supposed to be a list but isn't.

(defun japanese-get-definition (dictentry)
  "Get a definition from a dictionary entry."
  (let* (index 1)
    (save-match-data
      (and (string-match "/\\(.*?\\)$" dictentry)
           (setq definitions (split-string (match-string 1 dictentry) "/" t))
           (dolist (definition definitions)
             (setq definition (concat (int-to-string index) ". " definition))
             (setq index (+ index 1)))
           (mapconcat 'identity
                      definitions
                      "\n"))
      )
    )
  )
(japanese-get-definition "職業 [しょくぎょう] /(n,adj-no) occupation/business/")


texts: How to exclusively change color of pairs ()}]"'..)? As of now their face is default.


texts: How can I convert a list of integers to a string?

texts:
Let's say I have a list of integers, representing year, month, day for a date:

(2017 8 21)

and I want to format the list in one function call, as in

(format "%04d-%02d-%02d" 2017 8 21)

Is there an easy way to do this? I know I could assign the list to a variable and use elt to extract each element, but I'm hoping for a simpler solution.

(I really want to get YYYY-MM-DD for the first day of a given iso week, and has gotten so far as to that (math-date-to-dt (math-parse-iso-date (format "%04dW%02d1" year week))) will give me above mentioned list.)


texts: How to find heading substrings with org-mode internal links

texts:
With point over the link here, org-open-at-point jumps to the following line ("ham eggs"):

* spam
** spam [[ham%20eggs][ham eggs]]
** ham eggs

Here however (final line extended), the same action makes emacs prompt No match - create this as a new heading? (y or n) in the minibuffer:

* spam
** spam [[ham%20eggs][ham eggs]]
** ham eggs spam

Is it possible to define links that do a substring search, so that the search would succeed in this case?  It certainly is possible when linking to non-org mode files, and I would like to do the same for internal links.


texts: Since when the M-x shell open the shell on the other buffer?

texts:
I recently noticed the M-x shell command opens the shell in the other buffer.

I used to do Ctrl-x 3 > Ctrl-x o > M-x shell.

But recently I found that M-x shell opens the shell in the other buffer.
Was it changed? Or is there any possible mis-configuration?


texts:
I am running Emacs 26.1 on Ubuntu 16.4. I am writing Javascript using js2-mode. When the linter underlines a line of code, I want to know what error or warning it has detected. For example, in this code:

function() {
   return;
   return true;
}

js2-mode will underline the line

return true;

Because it cannot be reached after the first return statement, thus generating a warning. However, I cannot find anywhere where js2-mode actually shows me any text that explains why it has underlined that line. I gather that this should be possible, but the mode line and the mini buffer are both clear. Do I need to enable something or customize a variable?


texts: Copy or paste between terminal emacs 26 and Mac apps

texts:
I am using terminal emacs a lot, and the method from Copy text from Emacs to OS X clipboard works for a long time.

But after upgrading to Emacs 26, if I kill a string like "你好" from emacs, and paste here in the browser, it will be "‰Ω†Â•Ω". If I kill a string here "你好" and paste it in terminal emacs, it will be "??".

In short, the encoding is problematic.

My emacs version is: GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-04-13

(describe-coding-system)

Coding system for saving this buffer:
  Not set locally, use the default.
Default coding system (for new files):
  U -- utf-8 (alias: mule-utf-8 cp65001)

Coding system for keyboard input:
  U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)

Coding system for terminal output:
  U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)

Coding system for inter-client cut and paste:
  U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)

Defaults for subprocess I/O:
  decoding: U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)

  encoding: U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)

Priority order for recognizing coding systems when reading files:
  1. utf-8 (alias: mule-utf-8 cp65001)
  2. iso-2022-7bit
  3. iso-latin-1 (alias: iso-8859-1 latin-1)
  4. iso-2022-7bit-lock (alias: iso-2022-int-1)
  5. iso-2022-8bit-ss2
  6. emacs-mule
  7. raw-text
  8. iso-2022-jp (alias: junet)
  9. in-is13194-devanagari (alias: devanagari)
  10. chinese-iso-8bit (alias: cn-gb-2312 euc-china euc-cn cn-gb gb2312)
  11. utf-8-auto
  12. utf-8-with-signature
  13. utf-16
  14. utf-16be-with-signature (alias: utf-16-be)
  15. utf-16le-with-signature (alias: utf-16-le)
  16. utf-16be
  17. utf-16le
  18. japanese-shift-jis (alias: shift_jis sjis)
  19. chinese-big5 (alias: big5 cn-big5 cp950)
  20. undecided

Any hint?


texts: How to access Emacs LISP info manual on MSYS2 version of Emacs

texts:
I have been using MSYS2 to run Emacs. I would like to read the info documentation on E-LISP on my computer but the root node doesn't have any Emacs section. The menu command says there is [No match] for Emacs.

I haven't found a package on Emacs for the info files, nor has pacman been fruitful. Is there a package I'm forgetting? Do I simply need to accept that I have to read online documentation?

I have msys/info 6.6-1 (base) [installed]. I have GNU Emacs 26.2 (build 1, x86_64-w64-mingw32) of 2019-06-03.


texts: Make reftex-mode work with a different citation format

texts:
By default reftex-mode recognizes LaTeX-like citations, which have a format like \cite{Smith15}.  (Locating the cursor above a reference shows a description of it in the mini-buffer and pressing C-& opens the bibliography file in the right spot).

I would like reftex-mode to also recognize my Pandoc-like citations, which have a format like @Smith15 (regexp:"@[A-Z][A-Za-z0-9]+").

Reftex-mode has some functions that allow extending it (e.g., reftex-cite-format, reftex-view-crossref-extra), but it is not clear how to use them to detect this type of citation.

Any ideas?


texts: Control depth level of table of contents with org-mode and beamer

texts:
I have the following in my org-mode file that I am exporting to beamer on the basis of this simple template:

* Introduction
* More
** etc
* Still more
** Some a
** Some b
** Some c

However, my TOC only renders:

More
Still more

It neither renders the ** levels, nor the introduction, oddly.

I'm sure this setting exists, but I don't understand how to ask the TOC to render all ** levels.  What setting is controlling the level of TOC depth?


texts:
One of the options when installing emacs in OSX (through homebrew) is support for glib.  It's not included by default.  What does it buy me to install?  Any downsides?

Thanks!


texts: how do you disconnect ssh in emacs shell mode

texts:
In a regular terminal, I do

~ enter d

to disconnect from a ssh session.

sometimes I do ~ enter Ctl-z

to minimize/bg the ssh process

Is this possible while inside a M-x shell buffer in emacs.

(I use -nw terminal mode)


texts: Basic Org-mode: links handling - explanation of `C-c l` (manual unclear)

texts:
The compact org-mode guide says

C-c l

Store a link to the current location. This is a global command
(you must create the key binding yourself) which can be used
in any buffer to create a link. The link will be stored
for later insertion into an Org buffer (see below).`

Q1.

Clearly, I am not able to use the command C-c l, even though the org-mode is active.
Is this what they meant when the manual says: you must create the key binding yourself?

How can I do it?

Q2.

By the word global did they mean that we can use it in any other file to store the position and paste it in any other file or something else?

Q3.

What buffer is used to store this position? Can I access/see its contents without pasting the link using C-c C-l?


texts: How to display time in seconds in the mode line?

texts: By default display-time-mode shows the time only in minutes. How I can display time in seconds? Something like 18:34:45".


texts:
I want to replace some digits by letters such that

1 ---> a
2 ---> b
...

In emacs I have tried the following replacement:

M-x query-replace-regexp RET \([0-9]+\) RET \,(string (+ ?a \#1)) RET

It works, but in replacement I obtain 1 --> b, 2 --> c, and so on. Please, how can I fix it?

PS: I know that with my code 26 --> {, but it is not a problem because my digits are generally less than 26.


texts: Formatting of usepackage commands in LaTeX document

texts:
I'm trying to use AUCTeX edit LaTeX files. The beginning of the document I just wanted to edit looks like this:

It's not neatly organized, inconsistent in many ways, and I should probably change it but it's readable. (I didn't pick a nice example, I picked the document I wanted to edit which had parts of it copied in from various other documents which is why it's so inconsistent in the header.)

However, after I selected the entire contents of the document and pressed C-c C-q C-r (LaTeX-fill-region), it looked like this:

The rest of the document looked fine before and still looks fine. The header looked ugly before and now looks utterly ravaged.

Is there a way to correct this behavior?


texts: emacsclient unable to connect to daemon under snap installation of Emacs

texts:
I am facing with a well know problem, when I try to start emacs --daemon on a remote machine, I am getting following error emacsclient: connect: Connection refused:
$ ps aux | grep -E "[e]macs"  # returns empty
$ emacsclient -t -q doo.py
emacsclient: connect: Connection refused

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
## ...
Starting Emacs daemon.
Unable to start the daemon.
Another instance of Emacs is running the server, either as daemon or interactively.
You can use emacsclient to connect to that Emacs process.
Error: server did not start correctly
Error: Could not start the Emacs daemon

The way I connect into the remote machine ssh -Y4t user@IP zsh --login -i

I have done this set-up X11 Forwarding over ssh an it works, where xclock displays gui.
echo $DISPLAY => workstation:10.0

I don't know what can I debug more to handle this or what is the issue. I also have same configuration on a different remote machine where it works without a problem.

Update based on @phils guide(please see in comments) debug in depth.
$ kill -9 $(ps aux | grep -E "[e]macs" | awk '{print $2}')
$ ps aux | grep -E "[e]macs"  # returns empty
$ emacsclient -t -q doo.py
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.

$ ps aux | grep -E "[e]macs"  # returns empty
netlab    9885 14.1  0.4 464628 67812 ?        Ssl  01:40   0:04 /snap/emacs/296/usr/bin/emacs --daemon
$ kill -9 $(ps aux | grep -E "[e]macs" | awk '{print $2}')
$ ps aux | grep -E "[e]macs"  # returns empty

$ unset ALTERNATE_EDITOR
$ echo $ALTERNATE_EDITOR

$ ls -l /tmp/emacs1002/server
srwx------ 1 netlab netlab 0 Jul 16 01:40 /tmp/emacs1002/server
$ rm -rf /tmp/emacs1002/server
$ ls -l /tmp/emacs1002/server
ls: cannot access '/tmp/emacs1002/server': No such file or directory
$ emacsclient -t
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor.  Please use:

    --socket-name
    --server-file      (or environment variable EMACS_SERVER_FILE)
    --alternate-editor (or environment variable ALTERNATE_EDITOR)
$ emacs -Q --daemon

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Starting Emacs daemon.
$ ls -l /tmp/emacs1002/server
srwx------ 1 netlab netlab 0 Jul 16 01:42 /tmp/emacs1002/server
$  emacsclient -t
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor.  Please use:

    --socket-name
    --server-file      (or environment variable EMACS_SERVER_FILE)
    --alternate-editor (or environment variable ALTERNATE_EDITOR)


texts: Couldn't resize project sidebar is doom emacs

texts:
I'm using doom emacs.

I've enabled treemacs in ~/.doom.d/init.el

I couldn't resize the project sidebar. I have tried this mac OS and opensuse 15.1

I get message <left-fringe> <mouse-drag-1> is undefined. Do I miss any configuration?


texts: Org mode decorates some parts of text (like section headers with yellow), but I'd like to add other ones such as double quotes (such as strings when I am editing Lisp code).


texts: Auto pairs function expansion and deletion over return and backspace

texts:
I'm trying to find or configure some auto pairs plugin to do the following.
Say my cursor is placed as such:
fn() {|}

When I press enter, I want it to expand into:
fn() {
    |
}

I've found some plugins to do the above. However, I can't seem to find how to return to the following after pressing backspace twice:
fn() {|}

Instead, this happens:
fn() {|
}

I can't seem to find any documentation on how to do this, or what to even call this. I'd preferably want to do this with electric pair since it's the default, but anything works.


texts: go to symbol in javascript with web-mode

texts:
I am using web-mode for javascript files that contain jsx:

(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js[x]?$" . web-mode))

Is there a way to enable go to symbol with web-mode?


texts: Tutorial Exercise - C-x C-s Save -- Write Protected issue in OSX

texts:
I'm making my way through the tutorial and have run into an issue when trying to do the exercise on saving a file:

Saving file /~TUTORIAL...
basic-save-buffer-2: Directory / write-protected
Auto-saving...
Auto-saving ~TUTORIAL: Opening output file: Permission denied, /#~TUTORIAL#

The machine is mine, and so I have access everywhere, I think, and believe that I'm in my user directory to begin with.

Any ideas? Do I have to run the command as root?


texts: How to execute external commands from an Eshell script

texts:
I would like to create an elisp function such as

(defun script()
 (run "bash" "-c" "echo 1; sleep 3; echo 2")
 (eshell-print "Done"))

From an Eshell, its execution should look like:

eshell $ script
1
2
Done
eshell $

With the following requirements:

the stdout of the bash process has to be "streamed" in the eshell buffer.
it must be possible to C-c the script

Any idea on how to do that?


texts: What gets shown in *Messages* when I run pushd in shell, and how to modify it?

texts:
I use inferior shells (initiated with M-x shell) extensively.
If the current buffer is one such inferior shell, and within this shell I invoke the pushd command (with or without an argument), a space-separated list of directories gets written to *Messages*.  For example, what gets printed to the *Messages* buffer may look something like this
/some/path /some/other/path /yet/another/path ~/and/guess/what/one/more/path

This looks very much like a directory stack.
I find, however, that this directory-stack-like message is very often quite different from the output I actually get if I run dirs in the inferior shell.
Q1: how does Emacs figure out what to print to *Messages* when I invoke the pushd command in an inferior shell?
Q2: how can I reset Emacs' state so that what gets printed to *Messages* when I invoke the pushd command in an inferior shell is consistent with the output from running dirs in that shell?
One thing I can say is that running the Emacs command M-x dirs is not a suitable answer to Q2, primarily because, more often than not, when I run M-x dirs, Emacs just hangs, until I hit C-g.


texts:
There are two ways I start a new org-mode file:

1) I open Emacs and then by Ctr-x Ctr-f I type in the address of the location of where I want my file to be in.

2) I right click the place I want my file to be in and create a new Text Document. I name the document and modify the end by replacing .txt with .org

I find the second way faster but still not as fast as opening Notepad which I do just by typing in Note in the search bar (I am using Windows 10). Is there a way to open a new org-mode file as fast as opening Notepad?


texts:
In my emacs alias file located at .emacs.d/eshell/alias, I have the following:

alias mv mv -v $*

Whenever I execute the alias in eshell, for example: mv from_here.txt to_here.text, I get the error:

  mv: missing destination file or directory

How can this alias issue be fixed? Thanks.


texts: Meaning of character `C` in front of `dired` rows?

texts:
Some of my dired-rows are prefixed with an uppercase C character and I can't quite figure out what that should tell me. By experimenting around I managed to find out that the character doesn't seem to have any relation to unsaved or opened buffers. I tried to find a formal documentation describing the meaning of dired-columns but could neither find it via Google nor via C-h m.

So what does that character tell me?


texts: How do I eval a multiple line elisp expression inside the current buffer?

texts:
I am trying to delete all HTML style comments from my current buffer.

I found a solution in "Function to delete all comments from a buffer, without moving them to kill ring", but since it is more than two lines, M-x eval-expression does not work.

How do I evaluate a multiline elisp expression?


texts:
I'm relatively new to emacs and I'm trying my luck with doom emacs (I transitioned from spacemacs), and I've spent hours trying to figure out what's going on.
This is about ESS <RET> behavior. If my cursor is after the X in an R file inside an R package (a roxygen block), and I press enter, ESS should use ess-roxy-newline-and-indent and get me in a new line after a new #', but instead is doing a regular newline-and-indent .
#'
#' X
#'

If I use helpful-key and enter there, it tells me that newline-and-indent, rather than ess-roxy-newline-and-indent. However, if I use describe-key and enter there, it tells me the following:
RET (translated from <return>) runs the command newline-and-indent (found in
ess-roxy-mode-map), which is an interactive compiled Lisp function in
‘/snap/emacs/857/usr/share/emacs/27.1/lisp/simple.el’.

Its keys are remapped to ‘ess-roxy-newline-and-indent’. Without this remapping,
it would be bound to <remap> <newline>.

But it's not doing ess-roxy-newline-and-indent! I can put the cursor after the X, and alt-x ess-roxy-newline-and-indent and get the right output (a new line with #'  and the cursor). So I'm not sure what's going on.


texts: How to set image size in result of src block in Org mode

texts:
I've got a src block that has an image file as a result and I want that image file to be exported as a certain size.

I know I could apply the property #+ATTR_HTML: :width 100px, but I can't figure out a way to do that automatically when the result is produced.

The specific src block I'm using probably isn't necessary for an answer, but here it is anyway.

#+BEGIN_SRC python :noweb no-export :results file :exports both
<<extract-cells-from-table>>
image = cv2.imread("resources/examples/example-table.png", cv2.IMREAD_GRAYSCALE)
cell_images_rows = extract_cell_images_from_table(image)
cv2.imwrite("resources/examples/example-table-cell-1-1.png", cell_images_rows[1][1])
"resources/examples/example-table-cell-1-1.png"
#+END_SRC

#+RESULTS:
[[file:resources/examples/example-table-cell-1-1.png]]


texts:
I am writing source code and a lot of times I need to press Enter and have the newline indented with 4 spaces more than the previous. As I don't want to do it always, I would like to be able to use C-RET to achieve this.

While searching I found C-j (newline-and-indent) but it always indents with the same amount of spaces  and not relatively to the current line.

How can I achieve that?

To make myself clear, what I want is:

First line

/* Not indented. */

    Second line

    /* Second line indented with 4 spaces. */

        Third line

        /* Third line indented with 4 spaces
        but relative to the second so now it
        has 8 spaces. */


texts: Recognizing sentences that don't end in two spaces

texts: I'm not going to weigh in on whether ending sentences with two spaces is the One True Way or an abomination. All I know is that I show no signs of establishing a consistent habit of hitting the spacebar twice at the end of a sentence. So, given that: what's an ideal set of sentence-* customizations that will accurately recognize most English sentence endings without the aid of two spaces?


texts: I am running emacs as daemon, in MacOSX, it works flawlessly but when I kill the client the icon remains in the dock as running. I searched around for a way to hide it when no client is running but I couldn't find any workaround. Has anyone found a way to do this.


texts: White borders around text with theme org-beautify-theme

texts:
I'm using these themes in my init file (it's literally all that is in my init file):

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'org-beautify-theme t)
(load-theme 'zenburn t)

The result looks like this: http://i.imgur.com/npZaMXV.png

How do I get rid of these white borders? I think these borders are coming from the default white background color (if I disable the zenburn theme, the border blends into the white background).

I'm on Windows 7, Emacs version is 24.5.1.

By the way, it's really hard coming up with a tag if you don't have enough reputation to create new ones and you're left with no options because any other tag wouldn't make sense in this context... I tried 'theme', 'color', but they don't exist and so I had to put in some unrelated but existing tag like 'package' since it doesn't let me post the question without zero tags (which makes sense)...


texts: Leuven (and some other themes) show wrong code block background

texts:
Using emacs on Windows 10. The background colors of the begin, end, and code blocks don't continue to the ends of their lines. Since my .emacs file is rather short, I'll include it, too. Here's a picture:

The .emacs file:
(set-face-attribute 'default nil :font "Fira Code Retina" :height 120)
(load-theme 'tango-dark)

;; Disable blinking cursor
(blink-cursor-mode 0)

;; Initialize package sources
(require 'package)

;; package repositories
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                              ("melpa" . "https://melpa.org/packages/")
                                             ("org" . "https://orgmode.org/elpa/")
                                             ("elpa" . "https://elpa.gnu.org/packages/")))

;; initializes the package system to be ready to be used
(package-initialize)

;; a computer with a fresh install may not have a package archive
;; if there isn't one, refresh package list to make one
(unless package-archive-contents
  (package-refresh-contents))

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

(require 'use-package)
(setq use-package-always-ensure t)

(use-package doom-themes
  :config
  ;; Global settings (defaults)
  (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
        doom-themes-enable-italic t) ; if nil, italics is universally disabled
  (load-theme 'doom-one t)

  ;; Enable flashing mode-line on errors
  (doom-themes-visual-bell-config)

  ;; Enable custom neotree theme (all-the-icons must be installed!)
  (doom-themes-neotree-config)
  ;; or for treemacs users
  (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
  (doom-themes-treemacs-config)

  ;; Corrects (and improves) org-mode's native fontification.
  (doom-themes-org-config))

;; Download Evil if not installed
(unless (package-installed-p 'evil)
  (package-install 'evil))

;; Enable Evil
(require 'evil)
(evil-mode 1)

;; active Babel languages
(org-babel-do-load-languages
 'org-babel-load-languages
 '((java       . t)
   (python     . t)
;   (sh         . t)
   (emacs-lisp . t)
   (dot        . t)
   (css        . t)
   (C          . t)))

;; bidirectional writing
(defun set-bidi-env ()
  "interactive"
  (setq bidi-paragraph-direction 'nil))
(add-hook 'org-mode-hook 'set-bidi-env)

;; custom-set-variables works properly only if there's one instance of it

;; adds syntax highlighting & removes
;; "do you want to execute" when typing C-c C-c
(setq org-confirm-babel-evaluate nil
      org-src-fontify-natively t
      org-src-tab-acts-natively t)

(put 'downcase-region 'disabled nil)

(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

(defun my-bash-on-windows-shell ()
  (let ((explicit-shell-file-name "C:/Windows/System32/bash.exe"))
    (shell)))
(my-bash-on-windows-shell)

;; double the size of preview latex in org
(setq org-format-latex-options
      (plist-put org-format-latex-options :scale 2.0))


texts: Syntax highlighting for comments in text mode

texts:
From time to time I open a script or config file for which there is no major mode defined. When I invoke comment-region within that buffer, Emacs will prompt me for the comment syntax, and save it as the buffer-local variable comment-start.

Can I enable syntax highlighting of comment lines in that buffer?

Once the variable comment-start has been set, what other steps do I need to take in order for font-lock-mode to start highlighting my comment lines?


texts: Git bash opens in window outside of emacs

texts:
When running Emacs on Windows 10, I am able to launch git bash from within Emacs using the information given here, here, or here. For example, I can just add these two lines to my .emacs:

(setq explicit-shell-file-name "C:/Program Files/Git/git-bash.exe")
(setq explicit-bash.exe-args '("--login" "-i"))

Then, M-x shell opens a git bash.

However, git bash always opens in its own window, not as a buffer within Emacs. This is undesirable as it breaks my workflow within emacs. It also, apparently, isn't what usually happens, judging by the experience of other users.

Any ideas on how I can get git bash to open up within emacs? Thanks!


texts:
I am using web-mode to fold/unfold code. When I fold code, kill buffer and re open  it, code folding  disappears.

How to  preserve code folding even after killing  and  reopening buffer?


texts: How to translate between custom choice type and widget items?

texts:
I have a custom variable

(defcustom myvar ....
  :type '(choice (const :tag "foo" 1) ...))

and I need to map it to

(widget-create ...
               '(item :tag "foo" :value 1)
               ...)

Obviously I can write something like

(mapcar (lambda (item)
          `(item :tag ,(third item) :value ,(fourth item)))
        (rest (custom-variable-type 'myvar)))

but I was wondering if there is something more "official".


texts:
I'm new to emacs and playing around with org-mode. I have a text file that looks like this:

* Tasks
** task 1
** task 2
** TODO task 3
** DONE task 4
** TODO task 5

I open it with emacs and then go into org-mode.

Then it ends up looking like this:

* Tasks...

How do I expand the list?


texts: In org agenda mode, select several items, mark them with m, then set the todo status B t to none. Normally I can remove TODO status with t SPC but B t SPC isn't permitted.


texts: Unable to disable binding defined by undo-tree

texts:
There are two bindings for undo-tree-undo(C-_ and C-/) and undo-tree-redo(M-_ and C-?) defined in undo-tree, but now I don't want those bindings(delete those), I just want to bind C-z to undo-tree-undo and C-S-z to undo-tree-redo(short and simple), I tried

(define-key undo-tree-map (kbd "C-_") nil)

or

(global-unset-key (kbd "C-_"))

to delete the bindings, they all doesn't work(only work for current session), if I restart Emacs, the C-_ will still be bound to undo-tree-undo.

But if I set above two lines at the same time, the binding will be gone, that's really weird, how can I use one line to delete the bound.

BTW, if you can delete the old bindings and set the new binding(C-z) at the same time, that would be better?


texts: Use pkexec to run emacs in GUI mode with root privileges or any other way to do that

texts:
I've recently started learning to use Emacs.

I do not want to run emacs using sudo emacs (lets not ask why), so I tried using pkexec to start emacs with root privileges. However, pkexec emacs starts emacs in terminal mode. How can I solve this?

Or is there any other alternative where I can possibly use emacs to edit files with root privileges.

This is the custom policy:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD polkit Policy Configuration 1.0//EN"
"https://www.freedesktop.org/software/polkit/policyconfig-1.dtd">

<policyconfig>
    <action id="com.ubuntu.pkexec.emacs">
    <description>Run Emacs with root privileges</description>
    <message>
        Authentication is required to run Emacs with root privileges
    </message>
    <icon_name>Emacs</icon_name>

    <defaults>
        <allow_any>auth_admin</allow_any>
        <allow_inactive>auth_admin</allow_inactive>
        <allow_active>>auth_admin</allow_active>
    </defaults>

    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/emacs</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    </action>
</policyconfig>

Note:

A similar policy for brackets works fine.
Emacs starts in GUI mode if I use either emacs or sudo emacs in terminal.

Any help is appreciated.

Emacs version 24.5.1 in ubuntu 16.10


texts:
I want to open a python interpreter in a buffer with ipython. So I use that, from the term-mode :

(make-term "ipython" "/usr/bin/env" nil "ipython" (or filename "")
           "--TerminalIPythonApp.force_interact=True"))

But I don't know where to precise the python version that I want to use : my default version is python2.7 and I want to start an interpreter with python 3.4.


texts:
I've used emacs on Windows 10 for a year. Recently, my "box" cursor in emacs has become a thin vertical line.

I have tried setting the variable "cursor-type", but this no longer seems to have any effect.

I have found a short comment that emacs might be detecting assistive technology (like speech recognition) and using a system cursor.  See here.  I've tried turning off speech recognition in Windows, but that doesn't seem to fix the cursor in emacs.

Is there a way to force emacs to use a box cursor instead of a Windows native cursor? (If this is indeed my problem.)


texts: How do you change the paper size on pdf export in emacs?

texts:
Every time I export using the dispatcher, the pdf that is produced is letter size. My system and printer are A4.

How do I change the paper size for pdf (and text) exports in emacs?


texts: Why does the prompt remain even if I quit my command?

texts:
I'm trying to write a function that should allow me to conditionally choose how to replace a regexp. E.g. if I have the string "A. Z" I'd like to choose if replace it with "A@. Z" or "A.~Z".
I wrote this function:
(defun fix-latex-after-full-stop-space ()
  "DOCSTRING"
  (interactive)
  (save-excursion
    (let* ((a (point-min-marker))
           (case-fold-search nil)
           (case-replace nil))

      (catch 'quit
        (goto-char a)
        (while (search-forward-regexp  "[A-Z]\\. [A-Z]" nil t)
          (let* ((MATCH (match-string 0))
                 (CHOICE
                  (read-char-choice "Choose @, ~, \"n\" or \"q\"" '(?@ ?~ ?n ?q))))

            (cond ((char-equal CHOICE ?@)
                   (setq MATCH (replace-regexp-in-string
                                "\\. "
                                "\\@. "
                                MATCH t t
                                )))
                  ((char-equal CHOICE ?~)
                   (setq MATCH (replace-regexp-in-string
                                "\\. "
                                ".~"
                                MATCH t t
                                )))
                  ((char-equal CHOICE ?n)
                   nil
                   )

                  ((char-equal CHOICE ?q)
                   (throw 'quit nil)

                   ))
            (replace-match  MATCH t t))))
      )))

But it has a strange behaviour. If I type "q" to quit or when I replace the last match the prompt doesn't quit but keeps asking for a char.
Whats wrong in it?
You can test it on:
A. Z

A. Z

A. Z

Edit. It happens that if I add (princ "something") after the while loop the minibuffer quits like I expect:
(defun fix-latex-full-stop-space ()
  "DOCSTRING"
  (interactive)
  (save-excursion
    (let* ((a (point-min-marker))
           (case-fold-search nil)
           (case-replace nil))

      (catch 'quit
        (goto-char a)
        (while (search-forward-regexp  "[A-Z]\\. [A-Z]" nil t)
          (let* ((MATCH (match-string 0))
                 (CHOICE
                  (read-char-choice "Choose @, ~, \"n\" or \"q\"" '(?@ ?~ ?n ?q) t)))

            (cond ((char-equal CHOICE ?@)
                   (setq MATCH (replace-regexp-in-string
                                "\\. "
                                "\\@. "
                                MATCH t t
                                )))
                  ((char-equal CHOICE ?~)
                   (setq MATCH (replace-regexp-in-string
                                "\\. "
                                ".~"
                                MATCH t t
                                )))
                  ((char-equal CHOICE ?n)
                   nil
                   )

                  ((char-equal CHOICE ?q)
                   (throw 'quit nil)

                   ))
            (replace-match  MATCH t t))))
      (princ "") ;; <-- STRING ADDED HERE
      )))

but why?


texts: How to disable fill-column-indicator (fci) when it's outside the window?

texts:
*Edit* fci is no longer supported, emacs-27 supports this feature natively.

The are various known bugs with the fill-column indicator, there is one well known bug that occurs when the window is too narrow for the window.

Causing a column of $ to show on the right hand side of the window.

Since this has been broken for a while.
Is it possible to simply disable fci-mode when the window is too narrow to display it?


texts: Excluding frames from handout when exporting to LaTeX Beamer

texts:
I would like to exclude certain slides when I export my document as a handout using the corresponding option #+LaTeX_CLASS_OPTIONS: [handout].
I know what I need to arrive at in LaTeX to achieve this:
\begin{frame}<handout:0>
...
\end{frame}

And I know that I can use the property BEAMER_OPT in Org Mode to specify frame arguments like shrink that will be passed on as optional frame options in square brackets to get, e.g., \begin{frame}[shrink]:
* Slide title
  :PROPERTIES:
  :BEAMER_OPT: shrink
  :END:

However, how can I use Org Mode to properly pass on the <handout:0> option in the required format in angle brackets?


texts: I know about compose-region and have used it for other purposes, but am trying to figure out how to display a character reversed. like transforming c to ↄ. Is this possible?


texts: How to turn off automatic indenting for Org files in a specific folder?

texts:
I am using Doom Emacs. I like having indentation for most of my org files, but I have one folder where I want to have org files without indenting, to use for writing documents.
I have already tested adding #+STARTUP noindent, and that works per file, but I'm trying to find a way to make it the default for the folder.
I used add-dir-local-variable, to set org-indent-mode to nil, and I can see that was written to a .dir_locals.el in the folder I want to make the change for. But when I open an Org file it is still indented. If, after the file is open, I manually toggle org-indent-mode, I can turn the indenting on and off. Seems like maybe a matter of the sequence or I'm going about this the wrong way. If it helps, here is the .dir_locals.el
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((org-mode
  (org-indent-mode nil)))


texts:
I have a presentation I wrote using presentation mode a few years ago. Now I'm trying to open it and I forget how to do it.

I'm trying to run emacs command presentation-mode but nothing is found. I tried installing presentation-mode but there was no package with that name on Melpa. I also tried installing org-present but the command still doesn't work.

Is presentation mode built in to emacs or do I need to install it? Also how do I open it?


texts: Jump to file and line number in grep file

texts:
$ grep -nrH would . | tee file.txt
$ emacs file.txt

If I have a buffer with grep search results, how can I make Emacs jump to the file and line number on the cursor line, similar to diff-goto-source in diff-mode?

./path/to/my/one.txt:1234 RMS and YAK would hit it off
./other/two.txt:5678 They sure would

Furthermore, when I'm visiting the first file, one.txt, how can I make Emacs jump to the next file and line in the grep buffer, two.txt?


texts: How do I make lua indent two indentation units for a line continuation

texts:
For my current works style guide I need to indent two units (tabs in their case) for a line continuation. the default in emacs lua mode appears to be one.

e.g. (assuming two spaces are a tab or an indentation width)

correct example:

function doStuff(foo)
  local foo = otherFunc(
      someArgs,
      someMoreArgsToIllustrateIndentation)
  return foo
end

incorrect (default behaviour):

function doStuff(foo)
  local foo = otherFunc(
    someArgs,
    someMoreArgsToIllustrateIndentation)
  return foo
end

Now it seems like I need to modify lua-calculate-indentation in lua-mode.el but I can't seem to grok how it's working:

(defun lua-calculate-indentation (&optional parse-start)
  "Return appropriate indentation for current line as Lua code."
  (save-excursion
    (let ((continuing-p (lua-is-continuing-statement-p))
          (cur-line-begin-pos (line-beginning-position)))
      (or
       ;; when calculating indentation, do the following:
       ;; 1. check, if the line starts with indentation-modifier (open/close brace)
       ;;    and if it should be indented/unindented in special way
       (lua-calculate-indentation-override)

       (when (lua-forward-line-skip-blanks 'back)
         ;; the order of function calls here is important. block modifier
         ;; call may change the point to another line
         (let* ((modifier
                 (lua-calculate-indentation-block-modifier cur-line-begin-pos)))
           (+ (current-indentation) modifier)))

       ;; 4. if there's no previous line, indentation is 0
       0))))

Is this the right function to modify, and if so how do I do it?


texts: Is there any way to see what dependencies has a package installed? In other words what other packages were installed with the first one?


texts: commit by saving and then killing the COMMIT_EDITMSG buffer in magit?

texts:
I understand that in magit the normal way to commit after editing the commit message buffer would be C-c C-c

However in using git from the command line --- with Emacs as the editor for commit messages --- I have gotten used to the keystroke combination for saving the commit message C-x C-s and then killing the buffer C-x k Enter.  Is there a way I could continue to do this using magit?   In the default magit configuration, the normal keystrokes that I use for killing the buffer are aborting the commit.


texts: Yasnippet prompt when using commands interactively?

texts:
How can I use yasnippet to invoke LaTeX commands interactively?

If I use auctex to insert \usepackage it starts a minibuffer which lets me select the desired package (including tab completion). Similar for other commands like includegraphics. Is it possible to make yasnippet to do the same, i.e. help me choosing the package or image etc.?


texts: Yasnippets: loading two major modes (`org-mode` and `LaTeX`)

texts:
I'm trying to load the yasnippets for the LaTeX mode every time I open an org file.

Is it possible? How can this be achieved?


texts: Flycheck Emacs Lisp in Org-mode babel source blocks

texts:
I want to have Flycheck syntax checking when I am editing Emacs Lisp code in a literal Org-mode file using babel SRC blocks. (Using Org's editing buffers with C-c ').

However the flycheck-emacs-lisp checker predicate has the following to say:

  Ensure that we only check buffers with a backing file. For buffers without a backing file we cannot guarantee that file names in error messages are properly resolved, because `byte-compile-file' emits file names relative to the directory of the checked file instead of the working directory. Hence our backwards-substitution will fail, because the checker process has a different base directory to resolve relative file names than the Flycheck code working on the buffer to check.

So whenever I try to launch the checker I get predicate: nil in flycheck-verify-setup.

This is definitely a drawback in the literate-programming style. Is there a way to work around it so that source blocks can be checked?


texts: How to copy text without losing selection?

texts: When I copy some selected text (kill-ring-save with M-w), I automatically lose my selection. I have tried with Transient Mark Mode with no luck. (Note that I'm not using CUA Mode.)


texts: Is there a way to sort a list of packages in Package Menu (*Packages*) sorted by Version?  If you are using melpa, you see that melpa versions each package with %Y%m%d.%d.  I'd like to sort by the melpa version string.


texts:
I would like to view images using image-dired, then rename them. What I do at the moment:

Open image-dired with my directory of choice.
Mark an image that I want to rename.
In the corresponding dired+ buffer, I run wdired-change-to-wdired-mode, then rename the marked file.

Now image-dired still shows the renamed file, but it cannot be marked again in case I want that. The reason is that image-dired doesn't know about the rename.

Is there a way to rename images so that image-dired picks up the changes? Or is there a way to quickly refresh image-dired to pick up all changes in the current directory?


texts: Eshell and Dired are unable to extract port number from authinfo file

texts:
My default-directory is:  /ssh:lawlist@12.34.567.89#2222:/home3/lawlist

My .authinfo file contains:  machine 12.34.567.89 login lawlist password abcdefg

The above-combination works just fine.  However, I would like to remove #2222 from the default-directory and add port 2222 to my .authinfo file.

If I remove #2222 from the default-directory and add port 2222 to my .authinfo file, neither Eshell nor Dired permit me to login to the remote server.

Eshell:

Waiting for prompts from remote shell ...
Timeout reached, see buffer `*tramp/ssh lawlist@12.34.567.89*` for details.

Q:  How can I remove #2222 from my default-directory and force Eshell and/or Dired to extract port 2222 from my .authinfo file?

EDIT:  The following is rough draft to add this new feature.  A maintainer of Tramp, @Michael Albinus, has suggested that this may break other aspects of Tramp and he has invited a discussion on tramp-devel@gnu.org regarding this issue.

Ensure you are using a version of Emacs containing the December 17, 2015 bug fix to auth-source-ensure-strings that was resolved by commit 9384953:  https://github.com/jwiegley/emacs/commit/938495317a02b06a6c512832d0c6d9530fcd7f2b
Define the following function:

  (defun get-auth-info (host user &optional port)
  (let ((info (nth 0 (auth-source-search
                      :host host
                      :user user
                      :port port
                      :require '(:user :secret)
                      :create t))))
    (if info
       (let* ((port (plist-get info :port))
              (secret-maybe (plist-get info :secret))
              (secret
                (if (functionp secret-maybe)
                  (funcall secret-maybe)
                  secret-maybe)))
           (list port secret))
       nil)))

Comment out :port tramp-current-method in tramp-read-passwd.  tramp-current-method is "ssh" and this prevents auth-source-search from returning a result if .authinfo contains a specified port other than ssh; e.g., port 2222.
Within tramp-maybe-open-connection, comment out and replace this section as follows:

    ;; (when (string-match tramp-host-with-port-regexp l-host)
  ;;   (setq l-port (match-string 2 l-host)
  ;;         l-host (match-string 1 l-host)))

  (cond
    ((string-match tramp-host-with-port-regexp l-host)
      (setq l-port (match-string 2 l-host)
            l-host (match-string 1 l-host)))
    ((and l-host l-user)
      (let ((port (car (get-auth-info l-host l-user))))
        (when port
           (setq l-port port)))))